Reading xml with attributes in php



I have a xml. as shown in the attachment .. How can I read the contents via php


http://ift.tt/1DYumnB "XML"


Now I read this xml:



function RecurseXML($xml,$parent="")
{
$child_count = 0;
foreach($xml as $key=>$value)
{
$child_count++;

if(RecurseXML($value,$parent.".".$key) == 0) // no childern, aka "leaf node"
{

print($parent . "." . (string)$key . " = " . (string)$value . "<BR>\n");
}
}
return $child_count;
}

RecurseXML($result);


this result should look:



..
..
.Response.Hotels.Hotel.Room ID = 5556
.Response.Hotels.Hotel.Rooms.Room.Quantity = 0
.Response.Hotels.Hotel.Rooms.Room.MaxPax = 3
.Response.Hotels.Hotel.Rooms.Room.MinPax = 2
.Response.Hotels.Hotel.Rooms.Room.RoomType.languages.lang = Room Double Standard
.Response.Hotels.Hotel.Rooms.Room.RoomType.languages.lang = Camera single standard
...
...

No comments:

Post a Comment