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

The Archive Base Latest Questions

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

I have a xml document, i need to get name attribute’s value with helping

  • 0

I have a xml document, i need to get name attribute’s value with helping php. the xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:GetGoodsTreeResponse xmlns:ns2="http://b2b.alta.com.ge" xmlns:ns3="http://192.168.0.10/b2b">
         <ns3:GoodsTree level="0">
            <item id="010000000017337" level="0" name="COMPUTERS" is_open="N">
               <item id="015000000030431" level="1" name="ALTA" is_open="Y">
                  <item id="015000000030443" level="2" name="Zakaznoe Izdelie" is_open="N"/>
                  <item id="015002000031034" level="2" name="ATOM" is_open="N"/>
                  <item id="015005000030453" level="2" name="Celeron" is_open="N"/>
                  <item id="015010000030432" level="2" name="Dual Core" is_open="N"/>
                  <item id="015150000030778" level="2" name="i3" is_open="N"/>
                  <item id="015220000030775" level="2" name="i5" is_open="N"/>
                  <item id="015300000031827" level="2" name="i7" is_open="N"/>
               </item>
               <item id="010001005030300" level="1" name="Apple" is_open="N"/>
               <item id="010001001033496" level="1" name="Asus" is_open="N"/>
               <item id="010001001015793" level="1" name="Fujitsu" is_open="N"/>
               <item id="010001002015166" level="1" name="HP Compaq" is_open="N"/>
            </item>
          </ns3:GoodsTree>
      </ns2:GetGoodsTreeResponse>
   </S:Body>
</S:Envelope>

please help me i dont know what to do.. sorry for my english.

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

    You can use DOMDocument to parse that XML and get all items using DOMXpath, then loop in all items and get the attributes based on position (id = 0, name = 2), then create an new array that will hold all you item id’s with their names:

    $dom = new DOMDocument;
    $dom->loadXML($xml);
    
    $xpath = new DOMXPath($dom);
    $xpath->registerNamespace('S', 'http://schemas.xmlsoap.org/soap/envelope/');
    
    $items = array();
    
    $el = $xpath->query('//item');
    foreach($el as $item){
        $attributes = $item->attributes; 
        $items[$attributes->item(0)->value] = $attributes->item(2)->value;
    }
    
    var_dump($items); // $items will be an array with item id and it's value will be item name
    

    Codepad Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <gesmes:Envelope
Alright I have an xml document that looks something like this: <xml> <list> <partner>
I Have a XML document like below. i need to get record count for
I have a simple XML file that looks like this: <?xml version=1.0 ?> <devices>
I have an xml file which looked something like this... <RootElementTag> <ChildElementTag1 attribute1=value1 />
I have an XML file and I know the node name I need to
I have xml that looks somewhat similar to the following. I need to get
I have an XML document that includes XPath expressions that I need to use
I have a xml document. I know the index where i need to insert
I have the following xml document, I need an xquery expression to know how

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.