1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?php $string=" <result> <item> <id>1</id> <name>name 1</name> </item> <item> <id>2</id> <name>name 1</name> </item> </result>"; $xml = simplexml_load_string($string); //print_r($xml); foreach($xml->item as $item) { echo $item->id."\n"; } ?>
1 2