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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:26:54+00:00 2026-05-12T18:26:54+00:00

how do i get the list of children in xml->request->ABC ABC may have DEF,

  • 0

how do i get the list of children in xml->request->ABC
ABC may have DEF, ZZA, XAS, ETC and i would like to iterate through a list of these children (name required) instead of checking if they exist.

-edit-
Note: I am looking for the element name. I found an example which returns an attribute IF its known. How do i get the tag/element name?

  • 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-12T18:26:55+00:00Added an answer on May 12, 2026 at 6:26 pm

    Considering this piece of XML and the code to load it with SimpleXML :

    $str = <<<XML
    <xml>
        <request>
            <ABC>
                <DEF>glop</DEF>
                <ZZA>test</ZZA>
            </ABC>
        </request>
    </xml>
    XML;
    $xml = simplexml_load_string($str);
    

    What about using the children() method to get the list of all children of you ABC element, and loop over them with a foreach ?

    This way, for instance :

    foreach ($xml->request->ABC->children() as $a => $b) {
        echo "$a $b<br />";
    }
    

    And you’ll get this kind of output :

    DEF glop
    ZZA test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of Persons which has children [same type]. I get the
In my application i parse a xml from which I get a list of
I have such XMl <root> <list> <list> <topic></topic> <topic></topic> </list> <topic></topic> <topic></topic> </list> <topic></topic>
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
How do I get a list of all the children (Sprites) on the stage
I have an XML file that looks like this: <rss> <channel> <title>title</title> <link>link</link> <description>description</description>
I have xml file like this <bookstore> <book category=cooking> <title lang=en>Everyday Italian</title> <author>Giada De
I have an XML document like this <root> <item id=1 creator=me> <childA>1</childA> <childB>2</childB> </item>
i have class like below, public class SiteActionMap { public int Id { get;
I am inside a phtml file, how can I get the list of children

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.