I am trying to extract data from a structure that looks like http://chris.photobooks.com/xml/default.htm?state=8Tusing the following function I am trying to loop through every product tag\[code\]$dom = new DOMDocument;$dom->loadXML($resp);$xpath = new DOMXPath($dom);$xpath->registerNamespace('ns2', 'http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd');$xpath->registerNamespace('a', 'http://mws.amazonservices.com/schema/Products/2011-10-01');foreach($xpath->query('//aroduct') as $product){ echo $product->query('//ns2:ItemAttributes/ns2:Author')->item(0)->nodeValue}\[/code\]I now realize that this is the wrong way to extract data from within the for loop, but what is the correct way?