SimpleXML uses a set of classes which implement iterators to work through them, so you can loop through each node using foreach, however the easiest way to navigate the XML once it's loaded is by using SimpleXMLElement::xPath()
. To get revision 1558, you can make the following call:
$commit = $xml_list->xpath('//list/entry/commit[@revision="1558"]');
This will return you the nodes underneath <commit revision="1558">
, and you can then access them from the $commit
variable, which extends ArrayObject
.
To get the actual content of the <author>
element, you must do the following:
print((string)$commit[0]->author);
SimpleXMLElement
instances need to be cast to a type to expose their actual values.
Also, if you want to dump the content of $commit
to see its child nodes, the easiest way is to call the asXml()
method as follows:
print($commit[0]->asXml());