I have a relatively complex XML file which looks like the following but with many more 'Match' tags (something like 150 Entities, each containing 100+ 'Match' IDs):
<Entity>
<Name>Bill</Name>
<Watchlist>
<Match ID=1>
<Info></Info>
</Match>
<Match ID=2>
<Info></Info>
</Match>
...
<Match ID=99>
<Info></Info>
</Match>
</Entity>
I have written the following PHP to extract 'Info' from the 'Match' tag for every 'Entity' but it only extracts 'Info' the first of the 'Match' tags i.e. ID=1:
xml=simplexml_load_file($file) or die("Error: Cannot create object");
foreach($xml->children() as $i) {
echo "Name:" . $i->Name . " <br /> ";
echo "Info:" . $i->Watchlist->Match . " <br /> ";
}
What I want to do is extract the 'Info' from all the 'Match' tags for each 'Entity' so I can put them into a HTML table that will show the following:
Name Match
Bill ID=1>Info
Bill ID=2>Info
Bill ID=3>Info
...
Bill ID=99>Info
Any help to extract all the ID's would be much appreciated.
No comments:
Post a Comment