問題描述
我有一個類似的問題:https://superuser.com/questions/140242/why-my-browsers-display-xml-files-as-blank-pages?rq=1
我在瀏覽器中沒有看到我的 xml,而只是一個空白頁面.我只檢查了 Chrome 和 firefox,但兩者都發生了.不同之處在于我從 MySQL 獲取數據并對其進行響應.所以文件擴展名是 .php 而不是 .xml
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"?>
";
echo "<video>
";
echo "<path>" . $row['path'] . "</path>
";
echo "</video>
";
當我轉到 url 時看到一個空白頁.但是當我查看源代碼"時,我看到了 xml 樹.
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>
我的主要目標是獲取 xml 數據并使用 URLRequest() 在 Flash 中請求它.但是我收到這個錯誤
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.
我認為這可能是我在 Flash 中遇到的錯誤的問題.我只有一個根節點,我認為我的子節點沒有任何問題.所以我唯一的假設是錯誤是因為空白頁.
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.
推薦答案
XML 未顯示,因為瀏覽器會對其進行解釋.
The XML is not displayed because the browser interpret it.
寫作時
<table></table>
在您的 HTML 頁面中,您不會看到字符串
In your HTML page, you will not see the string
"<table><table>"
但是一張空桌子.
這與 XML 內容相同.
This is the same things about XML content.
另一個堆棧溢出帖子得到了這個答案這里
Another Stack overflow post got an answer to this HERE
這里我復制了mellamokb的回答
Here I copy past the answer of mellamokb
簡單的解決方案是嵌入元素內部,這將保留格式和尖括號.我也有刪除了 style="border:none;" 的邊框這使得 textarea看不見.
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.
這是一個示例:xxxx
Here is a sample: xxxx
這篇關于在 PHP 中回顯 xml 會在瀏覽器中顯示空白頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!