- $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, '
';
- }
复制代码
|