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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:39:45+00:00 2026-06-10T20:39:45+00:00

Here is the XML: <Routes> <Route type=source> <Table> <Tablename>incoming</Tablename> <Fields> <Fieldsname ref=description name=Route Name>description</Fieldsname>

  • 0

Here is the XML:

<Routes>
    <Route type="source">
        <Table>
            <Tablename>incoming</Tablename>
            <Fields>
                <Fieldsname ref="description" name="Route Name">description</Fieldsname>
                <Fieldsname name="CID Match">cidnum</Fieldsname>
                <Fieldsname name="DID Match">extension</Fieldsname>
                <Fieldsname ref="dest">destination</Fieldsname>
            </Fields>
        </Table>

    </Route>
</Routes>

Then my instantiation of it in PHP:

$doc    = new SimpleXMLElement('routingConfig.xml', null, true);

print_r($doc->Route[0]) shows this:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [type] => source
        )

    [comment] => SimpleXMLElement Object
        (
        )

    [Table] => SimpleXMLElement Object
        (
            [Tablename] => incoming
            [comment] => SimpleXMLElement Object
                (
                )

            [Fields] => SimpleXMLElement Object
                (
                    [Fieldsname] => Array
                        (
                            [0] => description
                            [1] => cidnum
                            [2] => extension
                            [3] => destination
                        )

                    [comment] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                )

                            [1] => SimpleXMLElement Object
                                (
                                )

                        )

                )

        )

)

Notice how the root value has the @attributes array. Why doesn’t $doc->Routes[0]->Table->Fields->Fieldsname have @attributes? I realize I can get it via attributes(), but is there a way to make it be included in $doc?

EDIT
Apparently print_r() doesn’t display every value in the array/object, exploring all children etc. Or perhaps SimpleXMLElement doesn’t return it unless requested (seems like it should all be stored in $doc). If you do print_r($doc->Route[0]->Table->Fields->Fieldsname[0]);, it returns

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [ref] => description
            [name] => Route Name
        )

    [0] => description
)

Which shows the data I am looking for. But if I do a print_r($doc->Route[0]->Table->Field); the data does not appear.

  • 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-10T20:39:47+00:00Added an answer on June 10, 2026 at 8:39 pm

    The SimpleXMLElement object does some very advanced things in PHP. It implements a lot of the “magic” hooks that PHP provides so that it works in things like foreach() and is meant to be treated like a “black box”. So because of that, using print_r() on it will give you misleading and incomplete information. You just can’t rely on print_r() (or var_dump()) on a SimpleXMLElement object.

    The way to debug the structure in a SimpleXMLElement is to simply look for the elements you’re after: things like isset($xmlnode->child) work, for instance. So is_array($doc->Route[0]->Table->Fields->Fieldsname) will be true.

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

Sidebar

Related Questions

Here is the XML: <Routes> <Route type=source> <Name>incoming</Name> <Table><Tablename>incoming</Tablename></Table> </Route> <Route type=dest> <Name>outgoing</Name> </Route>
Here's a quick one. In my navigation.xml I have this type of structure. <faq>
With glassfish, my persistence.xml is not loaded. my.ear META-INF/persistence.xml lib/entities.jar <!-- no persistence.xml here
Here is my XML: <section> <para>part1 <breakline/> part2 <list> <para>list1 </para> <para>list2 </para> </list>
Here is my XML Response: <DIDL-Lite xmlns=urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ xmlns:dc=http://purl.org/dc/elements/1.1/ xmlns:upnp=urn:schemas-upnp-org:metadata-1-0/upnp/ <item id=1182 parentID=40 restricted=1> <title>Hot
here is my xml DOM. <entities> <entity id=7006276> <title>xxx</title> <entities> <entity id=7877579> <title>xxx</title> <entities>
Here is my XML: [link]=> array(2) { [0]=> object(SimpleXMLElement)#244 (1) { [@attributes]=> array(3) {
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link
here is the XML file : <com.google.android.maps.MapView android:layout_width=fill_parent android:layout_height=fill_parent android:apiKey=0q7NUYm4bgzeXlqXtKYVPJDRWUJmt8Cu0gvbWMx android:id=@+id/map_view /> and Manifest
here is the xml data : <root> <recommendedMaterials> <value label=Aluminium data=0 /> <value label=Iron

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.