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 8642421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:46:19+00:00 2026-06-12T11:46:19+00:00

I am attempting to take a value from an attribute and use it in

  • 0

I am attempting to take a value from an attribute and use it in an array to insert it into a MySQL table. My XML file is:

    <?xml version="1.0"?>
<GetMatchingProductForIdResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<GetMatchingProductForIdResult Id="9780596515898" IdType="ISBN" status="Success">
<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>
  <Identifiers>
    <MarketplaceASIN>
      <MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
      <ASIN>B0026OR39Y</ASIN>
    </MarketplaceASIN>
  </Identifiers>

and using php I need to extract out the value of Id in GetMatchingProductForIdResult. So far my code is this:

    $parsed_xml = ProductId_xml($isbn);
    $isbn13 =(string)$parsed_xml->GetMatchingProductProductForIdResult[0]->attributes();
echo $isbn13['Id']; die;

I am getting no result from the echo statement, even if I change it to print_r or var_dump. I have also tried:

    $amazonResult = array(
                            'isbn' => $parsed_xml->GetMatchingProductProductForIdResult[0]['Id'],

Which yielded no results either. I am not sure where to go from here and any assistance will be greatly appreciated.

EDIT: To clarify this a little bit, the value in Id will change for each record. So what is “9780596515898” this time could be Id=”9780596312674″ for the next record. I need to know what each one is so I can insert them into the database with the other information I need.

  • 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-12T11:46:20+00:00Added an answer on June 12, 2026 at 11:46 am

    I can access the attributes if I close out the XML – otherwise all it does is throw errors.
    You can access all attributes, or individually through simplexml:

    $str = <<<XML
    <?xml version="1.0"?>
    <GetMatchingProductForIdResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
    <GetMatchingProductForIdResult Id="9780596515898" IdType="ISBN" status="Success">
    <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>
      <Identifiers>
        <MarketplaceASIN>
          <MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
          <ASIN>B0026OR39Y</ASIN>
        </MarketplaceASIN>
      </Identifiers>
    </Product>
    </Products>
    </GetMatchingProductForIdResult>
    </GetMatchingProductForIdResponse>
    XML;
    
    
    $xml = simplexml_load_string($str);
    
    foreach($xml->GetMatchingProductForIdResult->attributes() as $a => $b) {
        echo $a,'="',$b,"\"\n";
    }
    
    // Or access them directly:
    
    echo $xml->GetMatchingProductForIdResult->attributes()->Id;
    

    Outputs:

    Id="9780596515898" IdType="ISBN" status="Success" 9780596515898
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to take values from a XML file and put them into a
I'm attempting to take a string value from a Combo box then pass it
Attempting to use the data series from this example no longer passes the JSONLint
I am attempting to take the Name and ID fields from each object, but
I'm attempting to take 4-5 fields from a large django form and display them
Attempting to take the data in my gridview and convert it back into a
I am attempting to take two-digit integers representing day-of-month, split the digits into single
I am attempting to hash a string to a 64-bit value (bigint) in MySQL.
I'm attempting to calculate a specific y-value from a natural cubic spline given an
Hey everyone I'm attempting to take the value inputed in one of my forms,

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.