views:

497

answers:

1

How to display xml response already formatted in html (IE won't show anything after the xml table)

If you visit this page in IE you'll see that nothing displays after the chart: http://www.ratecatcher.com/prototype.htm

Here is the main php code:

$xml = file_get_contents($request); echo html_entity_decode($xml);

Then the html that is giving me problems:

the user in IE won't see anything after this.

Is there a better way to display the html than html_entity_decode? I've heard about simplexml but I don't know if it works with html.

Thanks for helping!

+1  A: 

You can try to use DOMDocument.

$dom = new DOMDocument('1.0', 'utf-8');
$dom->loadXML(file_get_contents($request));

echo $dom->saveXML(); // or saveHTML()
SleepyCod
Thanks for the quick answer - I forgot to say that I'm using php 4 still and these are the warning/errors it gave:Warning: domdocument() expects parameter 2 to be long, string given in /home/ratecat/public_html/0brchart.php on line 78Fatal error: Call to undefined function: loadxml() in /home/ratecat/public_html/0brchart.php on line 79
Sky
Try with the former PHP 4.x implementation. $dom = domxml_open_mem(file_get_contents($request)); echo $dom->html_dump_mem();
SleepyCod
Thank you sooo much SleepyCod!
Sky