PHP解析XML数据
时间:2021-07-01 10:21:17
帮助过:1人阅读
- $xml_string="
-
- ben
-
A -
-
- h2o
-
K -
";-
- //load the xml string using simplexml function
- $xml = simplexml_load_string($xml_string);
-
- //loop through the each node of molecule
- foreach ($xml->molecule as $record)
- {
- //attribute are accessted by
- echo $record['name'], ' ';
- //node are accessted by -> operator
- echo $record->symbol, ' ';
- echo $record->code, '
'; - }
|
PHP, XML