Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Parsing

Status
Not open for further replies.

alphador

Programmer
Joined
Dec 3, 2007
Messages
4
Location
IT
Hi, how would you parse in php an xml like this one:

Code:
<archive>
  <book name="AAA" />
  <collection>
    <book name="BBB" />
  </collection>
</archive>

If I use PHP function getElementsByTagName to get the tags "book" it returns both the one with name "AAA" and the one with name "BBB", but I want to get them separately, since they are at different levels.

Is this possible?

Thanks
 
Code:
$string = <<<XML
<archive>
  <book name="AAA" />
  <collection>
    <book name="BBB" />
  </collection>
</archive>
XML;
$xml = simplexml_load_string($string);
print_r($xml);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top