I'm trying to parse a "not-so-normal" XML web service. It appears the web service is returning a string, with XML inside that string.
The XML looks like this:
<string>
<NewDataSet>
<Table>
<CATID>0</CATID>
<DEPID>0</DEPID>
</Table>
<Table>
<CATID>1</CATID>
<DEPID>1</DEPID>
</Table>
</NewDataSet>
<string>
This is my code as of right now, I've already tried numerous variations but can't get anything to work. Most of the time it just returns nothing. I've echoed $xml and it will return all the XML, but I just need to show the CATID and nothing else.
<?php
$file = file_get_contents('http://theWebSericeLink.here');
$xml = simplexml_load_string($file);
//echo $xml;
foreach($xml->Table as $item) {
echo $item->CATID;
}
?>
I've also tried:
foreach($xml->NewDataSet->Table as $item)
and
foreach($xml->String->NewDataSet->Table as $item)
Thanks in advance.
simplexml_load_filewould load that XML file (URL) directly btw.