Forum Moderators: coopster

Message Too Old, No Replies

Strange problem reading XML

         

optik

9:58 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



I have a PHP page set up that generates XML.

I'm accessing this XML output from a different page but something is going wrong and the page isn't reading the XML properly (although it loads with no errors).

The strange thing is that it works if the XML contains multiple items but not if it only contains one

The basic structure is like this...

<container>
<item attr="val">
<info>some info</info>
</item>
<container>

and for multiple items (which works)

<container>
<item attr="val">
<info>some info</info>
</item>
<item attr="val">
<info>some info</info>
</item>
<container>

I'm using this kind of iteration and I have used this on normal xml file with one item and it worked fine.

$xml = $xmlRelease->getElementsByTagName('container');
foreach ($xml as $track) {

$items = $track->getElementsByTagName('item');

foreach ($items as $info) {
}

}

optik

10:51 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



don't worry it was a simple error elsewhere in the code