If i’ve xml feed back link as www.my_site.com/api.php?query=something
and the resulting is as following xml code
<api>
<page pageid="577" ns="0" title="something">
<extract xml:space="preserve">
blah blah about something blah blah
</extract>
</page>
</api>
Now how to parse this code to be shown as HTML ?! i’ve tried this idea but didn’t worked
<?PHP
$rssurl = "www.my_site.com/api.php?query=something";
$xml = @simplexml_load_file("$rssurl");
if($xml){
foreach ($xml->extract->item as $item) {
$desc = $item->extract;
$latestfeeds .= "$desc";
}
}else{
$latestfeeds = "Problem";
}
$body = "$latestfeeds";
echo $body;
?>
It keep giving me “Problem” ! this idea might be totally wrong so any help how to do it in order to get the content of extract blah blah about something blah blah ~ thanks
from XML to HTML there is no parsing, but a transformation. W3C define a language to be able to transform XML. XSL (extensible stylesheet language) can be usefull for you to use XSLT to transform XML to HTML. (see tutorial)