title: Call to a member function children() on a non-object
body: <p>I am getting this error when I try to extract information from an XML file.  The code to get the information is:</p>
  
  <pre><code>//retrieve amazon data
  $parsed_xml = amazon_xml($isbn);
  $amazonResult = array();
  
      //print_r($parsed_xml); die;
  $current = $parsed_xml-&gt;ListMatchingProductsResponse-&gt;ListMatchingProductsResult-&gt;Products-&gt;Product;
      //if($parsed_xml) {
  
          $amazonResult = array(
              'Title' =&gt; $current-&gt;AttributeSets-&gt;children('ns2')-&gt;ItemAttributes-&gt;Title,
              'SalesRank' =&gt; $current-&gt;SalesRankings-&gt;SalesRank-&gt;Rank,
              'ListPrice' =&gt; $current-&gt;AttributeSets-&gt;ItemAttributes-&gt;ListPrice-&gt;Amount,
              'ImageURL' =&gt; $current-&gt;AttributeSets-&gt;ItemAttributes-&gt;SmallImage-&gt;URL,
              'DetailURL' =&gt; $current-&gt;AttributeSets-&gt;ItemAttributes-&gt;SmallImage-&gt;URL,
  </code></pre>
  
  <p>and the XML file is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;ListMatchingProductsResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01"&gt;
  &lt;ListMatchingProductsResult&gt;
  &lt;Products xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd"&gt;
  &lt;Product&gt;
  &lt;AttributeSets&gt;
  &lt;ns2:ItemAttributes xml:lang="en-US"&gt;
  &lt;ns2:Title&gt;JavaScript: The Missing Manual&lt;/ns2:Title&gt;
  </code></pre>
  
  <p>When i run this I get a null value, and when I check the error log I get:
  Call to a member function children() on a non-object in ... on line 52.
  The offending line is:</p>
  
  <pre><code>'Title' =&gt; $current-&gt;AttributeSets-&gt;children('ns2')-&gt;ItemAttributes-&gt;Title,
  </code></pre>
  
  <p>The only items that have the namespace of ns2 are ItemAttributes and Title.</p>
  
  <p>How do I correct this so I can get the title information?
  Thanks</p>