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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:55:53+00:00 2026-06-11T23:55:53+00:00

Possible Duplicate: How to get an attribute with SimpleXML? How can I get the

  • 0

Possible Duplicate:
How to get an attribute with SimpleXML?

How can I get the values of height,length,weight and width? since it has attributes on it? In other values I have no problem in retrieving it, just this values has attributes.

Note:The height,length,weight and width part is only the problem

Here’s How I retrieve it:

$from_amazon = array(
   'asin'     => $item->ASIN,
   'product_name'
              => $item->ItemAttributes->Title, 
   'image'    => $item->SmallImage->URL,
   'price'    => $item->ItemAttributes->ListPrice->FormattedPrice, 
   'product_description'
              => $item->EditorialReviews->EditorialReview->Content,
   'category' => $item->ItemAttributes->ProductGroup,
   'weight'   => $item->ItemAttributes->PackageDimensions->Weight
);

XML DOM

  • 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-11T23:55:54+00:00Added an answer on June 11, 2026 at 11:55 pm

    The simplexml library will return you the object for that node. But you only want it’s text. Therefore you need to cast it to string:

    'weight'   => (string) $item->ItemAttributes->PackageDimensions->Weight
                  ^^^^^^^^
    

    That will give you the text as string of that XML node.


    In the Simplexml documentationDocs you find that in Example #6 Comparing Elements and Attributes with Text:

    To compare an element or attribute with a string or pass it into a function that requires a string, you must cast it to a string using (string). Otherwise, PHP treats the element as an object.

    (string) $movies->movie->title
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I only get the alt attribute of the a p
Possible Duplicate: PHP get values from SimpleXMLElement array SimpleXMLElement Object ( [@attributes] => Array
Possible Duplicate: SimpleXML get element content based on attribute value I've looked through several
Possible Duplicate: get name of current PHP script in include file Can an included
Possible Duplicate: How can I get the name of function inside a JavaScript function?
Possible duplicate: why does the css min-width attribute not force a div to hae
Possible Duplicate: Get the length of an audio file php i am using php
Possible Duplicate: Based on date, get todays and the next two days values from
Possible Duplicate: How to get text between div tags with id being 1st attribute.
Possible Duplicate: jQuery get all divs which do not have class attribute I need

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.