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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:53:55+00:00 2026-05-19T21:53:55+00:00

How do i get all the seat child nodes and their attributes from this

  • 0

How do i get all the “seat” child nodes and their attributes from this XML file?

   <seatmap id="1">
      <seat row="A" seatnum="01" available="1" />
      <seat row="A" seatnum="02" available="1" />
      <seat row="A" seatnum="03" available="1" />
      <seat row="A" seatnum="04" available="1" />
      <seat row="A" seatnum="05" available="1" />
    </seatmap>

I have different seatmaps, so i want to get them by querying with an ID
then assigning all the ‘seat’ nodes and their attributes to variables.

I’ve been using DOM methods so far, but maybe simpleXML or XPath would be easier as its really
confusing as you drill down from DOMDocumet, DOMElement, DOMNode.

Any help would be great, cheers!

  • 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-19T21:53:55+00:00Added an answer on May 19, 2026 at 9:53 pm
    $XML = <<<XML
    <parent>
       <seatmap id="1">
          <seat row="A" seatnum="01" available="1" />
          <seat row="A" seatnum="02" available="1" />
          <seat row="A" seatnum="03" available="1" />
          <seat row="A" seatnum="04" available="1" />
          <seat row="A" seatnum="05" available="1" />
        </seatmap>
    </parent>
    XML;
    
    $xml_nodes = new SimpleXMLElement($XML);
    
    $nodes = $xml_nodes->xpath('//seatmap[@id = "1"]/seat'); // Replace the ID value with whatever seatmap id you're trying to access
    
    foreach($nodes as $seat)
    {
        // You can then access: $seat['row'], $seat['seatnum'], $seat['available']
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to get all the element name from a xml file, for example
i am tryng to get all the td from each row in which colspan
How do I get all the TITLE and LINKS reading from a file ?
How do I get all the attributes that exist on a XML node? For
I am trying to get all the prime(row) numbered records from my table.Can someone
How can I get all items from a specific calendar (for a specific date).
I'm trying to get all property names / values from an Outlook item. I
I'm trying to get all my user's email from the production rails console. Problem
I am attempting to get all the data from a MySQL db with PHP,
How do i get all users from a specific role? var users = Membership.GetAllUsers();

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.