我正在使用以下代码来获取 XML,但是当我回显结果时,它在浏览器中不显示任何内容,但在源代码中显示它。
$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");
echo $contents;
这是 PHP 页面 我的测试页面
一旦我弄清楚了,我需要为 simpleXML 准备 $contents但我不确定我这样做是否正确?
$xml = <<<XML;
$xml .=$contents;
$xml .=XML;
echo $xml;
总结一下:
感谢您对问题 #1 的帮助,但我不完全清楚如何为 simpleXML 准备包含 XML 的变量。是否需要 << 和 XML;
?
问题 #2 如何在 <<
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");
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?
发布评论
评论(1)
您的网络服务器正在以
Content-Type:text/html; 的形式交付页面;字符集=UTF-8
。这会强制浏览器将内容视为 HTML,并且大多数元素都不是有效的 HTML 元素。一旦你解决了这个问题,IE 和 Firefox 应该直接显示 XML,而 Google Chrome 可能需要一些 援助。
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.