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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:24:13+00:00 2026-06-14T20:24:13+00:00

I have a xml string which looks like this, <xml> <type>name</type> <name> <namedata>abc</namedata> <namedata>efg</namedata>

  • 0

I have a xml string which looks like this,

 <xml>
   <type>name</type>
     <name>
        <namedata>abc</namedata>
        <namedata>efg</namedata>
        <namedata>ijk</namedata>
     </name>
 <xml>

REQUIREMENT:
I need to parse the xml to php and show it in a table such that it will display like this

   type   namedata   namedata   namedata
   name      abc        efg        ijk

I tried doing this using foreach but only could get the first value of namedata. Here is what i have done so far :

  $xml = simplexml_load_string($response);
  echo '<table>';
  echo '<tr><td>type'</td></tr>'.$xml->type.'</td><tr>';
  foreach($xml->name as $row){
     echo'<td>'.$row->namedata.'</td>';
    }
   echo'</tr></table>';
  • 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-14T20:24:14+00:00Added an answer on June 14, 2026 at 8:24 pm

    because there are multiple namdata nodes you can load them as an array like so:

    foreach($xml->name->namedata as $row){
        echo'<td>'.$row.'</td>';
    }
    

    as for this “Requirement”. The easiest way i found was something like:

    $xml = simplexml_load_string($response);
    echo '<table border="1">';
    echo '<tr><td>type</td>';
    for($x=0;$x<count($xml->name->namedata);$x++){
        echo '<td>namedata</td>';
    }
    echo '</tr><tr><td>'.$xml->type.'</td>';
    foreach($xml->name->namedata as $row){
        echo'<td>'.$row.'</td>';
    }
    echo'</tr></table>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some XML which looks like this: <Stat Type=first_name>[Value]</Stat> <Stat Type=last_name>[Value]</Stat> <Stat Type=known_name>[Value]</Stat>
...well, actually I have an object which looks like this: object(AleParserXMLElement)#39 (4) { [name:private]=>
I have code which parses XML that looks like this: <custom_fields> <custom_field> <column_name>foo</column_name> <column_value>0</column_value>
I have hash(Hash.from_xml) which looks like this (from inspect): { FileName=>hofplayers.xml, Version=>1.0, UserID=>3955847, FetchedDate=>2011-08-16
I have a XML Structure that looks like this. <sales> <item name=Games sku=MIC28306200 iCat=28
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
I have a string which has an xml inside. I want to write this
I have an XML string like <Segment xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:type=Air> <carrier /> ... </Segment> I
I have a AJAX requests which returns a string of XML which I'd like
I have an xml string such as this: <s:Envelope xmlns:s=http://schemas.xmlsoap.org/soap/envelope/> <s:Body> <ExecuteResponse xmlns=http://schemas.microsoft.com/xrm/2011/Contracts/Services> <ExecuteResult

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.