XML data shows in source not in browsers
I am using the following code to get XML but when I echo the result it shows nothing in the browser but shows it in the source.
$enc = urlencode('SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner=****ID******');
$contents = file_get_contents("https://api.facebook.com/method/fql.query?query=$enc开发者_Go百科");
echo $contents;
HERE IS THE PHP PAGE My Test Page
Once I get that figured out I need to prep $contents for simpleXML but I am not sure if I am doing it right?
$xml = <<<XML;
$xml .=$contents;
$xml .=XML;
echo $xml;
So to sum it up:
Thanks for you help with Issue #1 butI am not completely clear how to prepare a variable that contains XML for simpleXML. is the <<<XML
and the XML;
required?
Issue #2 How to add wrap the variable in the <<<XML and XML; tags?
Your web server is delivering the page as Content-Type:text/html; charset=UTF-8
. This forces the browser to treat the content as HTML, and most of your elements aren't valid HTML elements.
Once you sort that out, IE and Firefox should display the XML directly, while Google Chrome might need a bit of assistance.
精彩评论