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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)