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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:20:38+00:00 2026-06-05T09:20:38+00:00

I have a xml parser that returns an associative array. Here’s the structure: <addresses

  • 0

I have a xml parser that returns an associative array. Here’s the structure:

<addresses id="123">
  <anonymous-address> <test>data 1 </test>
  </anonymous-address>
</addresses>

print_r($this->params) will return 
Array
(
    [addresses] => Array
        (
            [id] => 123
            [anonymous-address] => Array
                (
                    [0] => Array
                        (                                
                            [test] => Array
                                (
                                    [VALUE] => data 1
                                )))))

This array then gets passed through list() as:

list($root, $data) = $parsedXML;

Then I attempt to get an id attribute from root and read to do it this way:

$id = $data[$root]['id'];

Edit: This works for all but one $root value which it 400’s for. This case of the switch ($root) has the same code as the others, so I have no idea why it errs only there.

var_dump($root, $data) outputs

string (9)  "addresses"
array(1)  {
    ["addresses"]=>
    array(2)  {
        ["id"]=>
        string(3)  "123"
        ["anonymous-address"]=>
        array(1)  {
            ["VALUE"]=>
            string(7)  "data 1 "
        }
    }
}
  • 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-05T09:20:40+00:00Added an answer on June 5, 2026 at 9:20 am
    $a = list($root, $data);
    

    now $a will be:

    array(0 => $root, 1 => $data);
    

    so you can get them like this:

    $a[0], $a[1]
    

    so probably

    $id = $a[1][$a[0]]['id'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a XML parser that list correctly in the UITableViewController. It passes
I am using XML parser.In that i have to pass one id from one
I have a buggy xml that contains empty attributes and I have a parser
I have the following simple XML structure that has to be parsed: <Nodes> <Node
I have an asp.net asmx webmethod that returns the following response: <?xml version=1.0 encoding=utf-8?>
I have a SOAP web service that returns an XML in this format <SOAP-ENV:Envelope
I have WCF service that returns an object that contains an array of bytes
I have an .asmx webservice that returns some XML. A sample bit of XML
I have a PHP webservice that returns an XML output, and one of the
I want to parse xml files that have elements like these: <element>&amp</element> <element>&amp;</element> But

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.