Have a Snippet?

Keep, track and share your code snippets with your friends

PHP: Parse XML Share on Vkontakte

Parse XML via SimpleXML

$xml_string = " 
     
        
          John Doe 
          
        
        
          Joanna Doe 
          
        
    ";
$xml = simplexml_load_string($xml_string);

foreach ($xml->user as $user) {
    //Get "id" and "status" attributes
    echo $user['id'].' ('.$user['status'].')
'; //Get subnodes echo $user->username. '
'; echo $user->useremail. '
'; }


Tag: PHP, XML, parser, SimpleXML

0 Comments