首页  >  文章  >  后端开发  >  PHP解析 XML 数据

PHP解析 XML 数据

WBOY
WBOY原创
2016-07-25 08:42:421210浏览
  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


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn