l'esempio che interessa a te è questo:
Se guardi l'xml di esempio contiene questi nodi:codice:<?php include 'example.php'; $xml = new SimpleXMLElement($xmlstr); /* Access the <rating> nodes of the first movie. * Output the rating scale, too. */ foreach ($xml->movie[0]->rating as $rating) { switch((string) $rating['type']) { // Get attributes as element indices case 'thumbs': echo $rating, ' thumbs up'; break; case 'stars': echo $rating, ' stars'; break; } } ?>
Il fatto che tu lo carichi da file non cambia nulla, perchè quello che ottieni è sempre un oggetto simplexml.codice:<rating type="thumbs">7</rating> <rating type="stars">5</rating>
ciao

Rispondi quotando