PHP parses XML data

WBOY
Release: 2016-07-25 08:42:42
Original
1210 people have browsed it
  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


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template