php parsing xml result from ipb ssi tool
Posted
by
Sir Troll
on Stack Overflow
See other posts from Stack Overflow
or by Sir Troll
Published on 2012-08-30T20:05:31Z
Indexed on
2012/08/30
21:38 UTC
Read the original article
Hit count: 395
Last week my code was running fine and now (without changing anything) it is no longer able to parse the elements out of the XML.
The response from the ssi tool:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ipbsource><topic id="32">
<title>Test topic</title>
<lastposter id="1">Drake</lastposter>
<starter id="18">Drake</starter>
<forum id="3">Updates</forum>
<date timestamp="1345600720">22 August 2012 - 03:58 AM</date>
</topic>
</ipbsource>
enter code here
Update: Switched to SimpleXML but I can't extract data from the xml:
$xml = file_get_contents('http://site.com/forum/ssi.php?a=out&f=2&show=10&type=xml');
$xml = new SimpleXMLElement($xml);
$item_array = array();
var_dump($xml);
foreach($xml->topic as $el) {
var_dump($el);
echo 'Title: ' . $el->title;
}
The var_dump output:
object(SimpleXMLElement)#1 (1) { [0]=> string(1) " " }
© Stack Overflow or respective owner