How can I access an element of type <game: title> using simplexml?
I am trying to parse an XML feed using SimpleXML, here is a snippet of the XML tree:
<item>
<game:name>Tetris</game:name>
<game:desc>Way Cool Game</game:desc>
<size>5mb</size>
</item>
Actually, I can successfully access the "size" with something like this: $item->size
but how do I get the value? Of course, I can't call that:, $item->game:name
and I don't know how the call goes after: '. Is it a parameter, an attribute, or what?
Thanks for the advance!
+2
source to share
3 answers
Use the children () function to get the children of the namespace.
$useThis = $xmlDoc->children("http://game.namespace/");
given that http: //game.namespace is the url of your games namespace in the root node.
Here's an explanation / sample:
+2
source to share