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

  • Home
  • SEARCH
  • 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 7044613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:25:50+00:00 2026-05-28T02:25:50+00:00

Hi im trying to parse XML with simplexml. The problem is i cannot access

  • 0

Hi im trying to parse XML with simplexml. The problem is i cannot access atributtes, any ideas why?

PHP code:

$xml = simplexml_load_file($source);
foreach($xml->children() as $node) {
     foreach ($node->AttrList->attributes() as $attribute) {
          print_r ($attribute);
     }
}

Piece of XML:

<ProductCatalog>
  <Product>
    <ProductCode>ST905003FND2E1-RK</ProductCode>
    <Vendor>SEAGATE</Vendor>
    <ProductType>HDD External</ProductType>
    <ProductCategory>Cietie diski</ProductCategory>
    <ProductDescription>HDD External SEAGATE FreeAgent Go 5400.2 (2.5",500GB,8MB cache,USB 2.0,FreeAgent software) Black</ProductDescription>
    <Image>https://www.it4profit.com/catalogimg/wic/1/ST905003FND2E1-RK</Image>
    <ProductCard>https://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=90728055033221913&amp;THEME=asbis&amp;LANG=lv</ProductCard>
    <AttrList>
      <element Name="Device Location" Value="External"/>
      <element Name="Hard Drive Type" Value="Portable"/>
      <element Name="Form Factor" Value="2.5&quot;"/>
      <element Name="Storage Capacity" Value="500000 MB"/>
      <element Name="Supports Data Channel" Value="USB 2.0"/>
      <element Name="Installed Cache Memory Storage Capacity" Value="8 MB"/>
      <element Name="Sector Capacity" Value="512 B"/>
      <element Name="Rotational Speed" Value="5400 rpm"/>
      <element Name="External Data Bit Rate" Value="480 Mbps (Max)"/>
      <element Name="USB2.0  Interface Quantity" Value="1"/>
      <element Name="Platform Compability" Value="PC"/>
      <element Name="Software Included" Value="FreeAgent software"/>
      <element Name="Requires Operating System" Value="Microsoft Windows XP, Microsoft Windows Vista"/>
      <element Name="Requires Peripheral Devices" Value="USB 2.0 port"/>
      <element Name="Cable Included" Value="USB Cable"/>
      <element Name="External Color" Value="Black"/>
      <element Name="Case Material" Value="Plastic"/>
      <element Name="Depth" Value="146.1 mm"/>
      <element Name="Height" Value="177.8 mm"/>
      <element Name="Width" Value="50.8 mm"/>
      <element Name="Nominal Weight" Value="0.3 kg"/>
      <element Name="Warranty Products returnable" Value="Yes"/>
      <element Name="Warranty Term (month)" Value="60 month"/>
      <element Name="Warranty validation Criteria" Value="Serial Number"/>
      <element Name="Box Depth (mm)" Value="196 mm"/>
      <element Name="Box Height (mm)" Value="501 mm"/>
      <element Name="Box Weight Brutto (kg)" Value="4 kg"/>
      <element Name="Box Width (mm)" Value="297 mm"/>
      <element Name="Pack Depth (mm)" Value="178 mm"/>
      <element Name="Pack Height (mm)" Value="178 mm"/>
      <element Name="Pack Weight Brutto (kg)" Value="0.57 kg"/>
      <element Name="Pack Width (mm)" Value="89 mm"/>
      <element Name="Packs in Box" Value="6"/>
      <element Name="Pieces in pack" Value="1"/>
      <element Name="EAN Code" Value="7636490016813"/>
    </AttrList>
    <MarketingInfo>
      <element>The ultimate portable storage solution with the world㠔s first hard drive docking station for easy access to all your stuff. Sleek, ultra-thin design that㠔s as stylish as it is striking. &lt;br&gt;&lt;br&gt; &lt;ul&gt;&#13;
&lt;li&gt;Store photos, music, and other files&#13;
&lt;li&gt;Carry your data anywhere you want&#13;
&lt;li&gt;Sync data between computers&#13;
&lt;li&gt;Back up files using the optional dock&#13;
&lt;/ul&gt;</element>
    </MarketingInfo>
    <Images>
      <Image>https://content.it4profit.com/pimg/s/resize/160x160x160x160/90818105858024672.jpg</Image>
      <Image>https://content.it4profit.com/pimg/s/resize/400x300x400x300/90818105819015057.jpg</Image>
      <Image>https://content.it4profit.com/pimg/s/resize/200x150x200x150/90818105848608387.jpg</Image>
      <Image>https://content.it4profit.com/pimg/s/resize/75x56x75x56/90818105909870954.jpg</Image>
      <Image>https://content.it4profit.com/pimg/s/resize/362x362x362x362/90818105833910289.jpg</Image>
      <Image>https://content.it4profit.com/pimg/s/resize/260x195x260x195/90818105841219714.jpg</Image>
    </Images>
  </Product>
</ProductCatalog>
  • 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-05-28T02:25:50+00:00Added an answer on May 28, 2026 at 2:25 am

    It’s not displaying anything because the <AttrList> node doesn’t have any attributes.

    Did you mean?

    foreach($xml->children() as $node) {
         foreach ($node->AttrList->children() as $child) {
            foreach($child->attributes() as $attribute) {
                echo $attribute->getName() , " - " , $attribute , "\n";
            }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse some XML using simpleXML in PHP. The problem I'm having
Hi Im trying to parse an xml feed using simplexml in php. The xml
I'm trying to parse out the XML below with the PHP code shown here
I'm trying to parse a moderately large XML file (6mb) in php using simpleXML.
I'm trying to parse some xml using simplexml and php...it's being returned to me
I am beginner in PHP. I am trying to parse this xml file. <relationship>
I'm trying to parse an XML file using PHP, but I get an error
I'm trying to parse a XML file, but when loading it simpleXML prints the
I'm trying to parse XML feed with SimpleXML, here is a chunk of the
I am trying to parse XML using PHP DOM and then insert this data

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.