Heim  >  Artikel  >  Backend-Entwicklung  >  PHP解析 XML 数据

PHP解析 XML 数据

WBOY
WBOYOriginal
2016-07-25 08:42:421152Durchsuche
  1. $xml_string="
  2. ben
  3. A
  4. h2o
  5. K
  6. ";
  7. //load the xml string using simplexml function
  8. $xml = simplexml_load_string($xml_string);
  9. //loop through the each node of molecule
  10. foreach ($xml->molecule as $record)
  11. {
  12. //attribute are accessted by
  13. echo $record['name'], ' ';
  14. //node are accessted by -> operator
  15. echo $record->symbol, ' ';
  16. echo $record->code, '
    ';
  17. }
复制代码

PHP, XML


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP根据 URL 下载图片 Nächster Artikel:whois 查询的PHP代码