PHP: Parse XML
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