The alternative to DOMXPath is using SimpleXML. It isn't as powerful as the DOM version, but as the name suggests it's quite simple and easy when accessing data (not so flexible in creating data though).
Using the sample you have, the two ways of doing this are...
<?php
error_reporting ( E_ALL );
ini_set ( 'display_errors', 1 );
$xml = <<<XML
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<numbers>
<number no_id="4" number_name="car" />
<number no_id="6" number_name="bike" />
<number no_id="11" number_name="train" />
<number no_id="32" number_name="plane" />
</numbers>
</rss>
XML;
$response = new SimpleXMLElement($xml);
echo "Element access:".PHP_EOL;
foreach ($response->numbers->number as $number ) {
echo $number['number_name'].PHP_EOL;
}
echo "XPath:".PHP_EOL;
$xp = $response->xpath('//number');
foreach ($xp as $number ) {
echo $number['number_name'].PHP_EOL;
}
Which gives you output of...
Element access:
car
bike
train
plane
XPath:
car
bike
train
plane