在PHP中回声xml给出浏览器中的空白页面 [英] Echoing xml in PHP gives blank pages in Browser
问题描述
我有类似的问题:
https://superuser.com/questions/140242/why-my-browsers-display-xml-files-as-blank-pages?rq=1
我在浏览器中看不到我的xml,但只是一个空白页面。我只检查了Chrome和Firefox,但这两者都发生了。
区别在于我从MySQL获取数据并对其进行回显。所以文件扩展名是.php,而不是.xml
$ row = mysqli_fetch_assoc($ resource);
echo<?xml version = \1.0 \encoding = \UTF-8 \?>> \\\
;
回显< video> \\\
;
回显<路径> 。 $ row ['path']。 < /路径> \\\
;
回显< / video> \\\
;
当我转到网址时,我看到一个空白页面。但是当我查看源代码,我看到的XML树。
< video>
<路径> URLtoVideo.mp4< / path>
< / video>
我的主要目标是获取xml数据并使用URLRequest()在Flash中请求它。但是我得到这个错误
$ b $ pre $ TypeError:错误#1088:跟在根元素之后的文档中的标记必须是格式良好的。
我认为这可能是我在Flash中遇到的错误的问题。我只有一个根节点,我不认为我有任何问题的子节点。所以,我唯一的假设是,错误发生是因为空白页面。
不显示XML,因为浏览器解释它。
当您写入
< table>< / p&表>
在您的HTML页面中,您将看不到字符串
< table>< table \>
但是一张空表。
是关于XML内容的同样的东西。
另一个堆栈溢出帖子得到了一个答案这里
这里我复制了mellamokb的答案
简单的解决方案是嵌入到元素内部,
保存格式和尖括号。我还有
删除了style =border:none;的边框这使得textarea
不可见。
下面是一个示例:xxxx
I have a similar question to this: https://superuser.com/questions/140242/why-my-browsers-display-xml-files-as-blank-pages?rq=1
I don't see my xml in my browser, but just a blank page. I only checked Chrome and firefox, but it's happening in both. The difference is that I'm getting data from MySQL and echoing it. So the file extension is .php and not .xml
$row = mysqli_fetch_assoc($resource);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<video>\n";
echo "<path>" . $row['path'] . "</path>\n";
echo "</video>\n";
I see a blank page when I go to the url. But when I "View Source", I see the xml tree.
<video>
<path>URLtoVideo.mp4</path>
</video>
My main goal is to grab the xml data and request it in Flash using URLRequest(). But I get this error
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
I think this may be the problem to the error I get in Flash. I only have one root node, and I don't think I have any problems with the child nodes. So my only assumption is that the error occurs because of the blank page.
The XML is not displayed because the browser interpret it.
When you write
<table></table>
In your HTML page, you will not see the string
"<table><table\>"
But an empty table.
This is the same things about XML content.
Another Stack overflow post got an answer to this HERE
Here I copy past the answer of mellamokb
Simple solution is to embed inside of a element, which will preserve both the formatting and the angle brackets. I have also removed the border with style="border:none;" which makes the textarea invisible.
Here is a sample: xxxx
这篇关于在PHP中回声xml给出浏览器中的空白页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!