I need to extract info from an xml document's outermost node (the document itself). using the xml below:
<?xml version="1.0" encoding="UTF-8" ?>
<revue date="2015" issue="12345">
<innernode>Oi</innernode>
</revue>
i would like to extract 2015
and 12345
. i fail if i attempt to read the node revue
using a foreach loop
foreach ($xml->revue as $revueIn) {
foreach ($revueIn->attributes() as $z => $y) {
to see if i have typos or something, i inverted innernode
and revue
<?xml version="1.0" encoding="UTF-8" ?>
<innernode>
<revue date="2015" issue="12345">Oi</revue>
</innernode>
and above code worked (found the revue
node and read its attributes correctly)
therefore, it seems to me that the outermost node is treated/perceived differently by SimpleXML.
does anyone know how to access the outermost node? tks in advance 4 your time.
Aucun commentaire:
Enregistrer un commentaire