问题
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.
回答1:
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
回答2:
Try adding an XML header before your output. Your browser is trying to read it like HTML otherwise
header('Content-type: text/xml');
回答3:
You need to make and xml object/element and then echo it, plus dont forget to add header('Content-Type: text/xml'); before echo.
For more refer this link http://php.net/manual/en/simplexml.examples-basic.php
来源:https://stackoverflow.com/questions/25145446/echoing-xml-in-php-gives-blank-pages-in-browser