Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:10:23+00:00 2026-06-07T09:10:23+00:00

I am getting this error when I try to extract information from an XML

  • 0

I am getting this error when I try to extract information from an XML file. The code to get the information is:

//retrieve amazon data
$parsed_xml = amazon_xml($isbn);
$amazonResult = array();

    //print_r($parsed_xml); die;
$current = $parsed_xml->ListMatchingProductsResponse->ListMatchingProductsResult->Products->Product;
    //if($parsed_xml) {

        $amazonResult = array(
            'Title' => $current->AttributeSets->children('ns2')->ItemAttributes->Title,
            'SalesRank' => $current->SalesRankings->SalesRank->Rank,
            'ListPrice' => $current->AttributeSets->ItemAttributes->ListPrice->Amount,
            'ImageURL' => $current->AttributeSets->ItemAttributes->SmallImage->URL,
            'DetailURL' => $current->AttributeSets->ItemAttributes->SmallImage->URL,

and the XML file is:

<?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>

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:

'Title' => $current->AttributeSets->children('ns2')->ItemAttributes->Title,

The only items that have the namespace of ns2 are ItemAttributes and Title.

How do I correct this so I can get the title information?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:10:24+00:00Added an answer on June 7, 2026 at 9:10 am

    ns2 is a prefix, not the actual namespace,and ListMatchingProductsResponse is the root-node, no need to mention it, so:

    var_dump(
            $parsed_xml->ListMatchingProductsResult
                    ->Products
                    ->Product
                    ->AttributeSets
                    ->children('ns2',true)
                    ->ItemAttributes
                    ->Title);              
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error when I try to retrieve some data. Here is
I am getting this error when I try to build for the device: Code
I'm getting this error when I try to mail from CakePHP 2.0 using CakeEmail:
I'm getting this error in ElementTree when I try to run the code below:
I am getting this error when I try to read a property from a
I am getting this error when I try to run Junits from ANT task.
I am getting this error when I try to open a file: java.io.FileNotFoundException: D:\Portable%20Programs\Android%20Development\workspace3\XXX-desktop\bin\World_X.fr
Getting this error when try to add an item to my repositories/context: Collection has
I am getting this error when I try to deploy my Web API project
I'm getting this error when I try run DB:Rake : ** Invoke db:migrate (first_time)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.