在 PHP 中回显 xml 会在浏览器中显示空白页面

Echoing xml in PHP gives blank pages in Browser(在 PHP 中回显 xml 会在浏览器中显示空白页面)
本文介绍了在 PHP 中回显 xml 会在浏览器中显示空白页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个类似的问题: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 会在浏览器中显示空白页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Encryption in JavaScript and decryption with PHP(JavaScript 加密和 PHP 解密)
Best solution to protect PHP code without encryption(无需加密即可保护 PHP 代码的最佳解决方案)
PHP AES encrypt / decrypt(PHP AES 加密/解密)
Upgrading my encryption library from Mcrypt to OpenSSL(将我的加密库从 Mcrypt 升级到 OpenSSL)
How to add/remove PKCS7 padding from an AES encrypted string?(如何从 AES 加密字符串中添加/删除 PKCS7 填充?)
How do I upgrade from PHP 7.0 to 7.3 on google cloud platform?(如何在谷歌云平台上从 PHP 7.0 升级到 7.3?)