I am trying to get the information out of an xml string and view the child nodes in it. I am using:
'Title' => $current->AttributeSets->children('ns2')->ItemAttributes->Title,
in an array where $current
$current = $parsed_xml->ListMatchingProductsResponse->ListMatchingProductsResult->Products->Product;
the namespace is ns2 and the children are ItemAttributes and Title. When I run this I get no information where the title should be. Here is the response when I run the script:
SimpleXMLElement Object()
Can anyone point me in the right direction please? I have looked at the other posts and have tried to use their examples but they are not working for me.
Here is the XML:
<?xml version="1.0"?>
<ListMatchingProductsResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<ListMatchingProductsResult>
<Products xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd">
<Product>
<AttributeSets>
<ns2:ItemAttributes xml:lang="en-US">
<ns2:Title>JavaScript: The Missing Manual</ns2:Title>
In case anyone else needs to do something similar, the correct way to get the children information is:
String is not needed, but true is.