/ Published in: PHP
Expand |
Embed | Plain Text
<?php //xml string $xml_string="<?xml version='1.0'?> <users> <user id='398'> <name>Foo</name> <email>[email protected]</name> </user> <user id='867'> <name>Foobar</name> <email>[email protected]</name> </user> </users>"; //load the xml string using simplexml $xml = simplexml_load_string($xml_string); //loop through the each node of user foreach ($xml->user as $user) { //access attribute //subnodes are accessed by -> operator } ?>
Comments
Subscribe to comments
You need to login to post a comment.

very helpful code snippet. however I need help on the following.
Sample xml
20100103 22:44
How do I get the value for 'Updatetime' ?
Oh no! I didn't know that my mark up will be trimmed down.. Please ignore the above comment..