SimplePie XML 文档无效

发布于 2024-09-08 16:54:34 字数 889 浏览 4 评论 0原文

我正在尝试使用 SimplePie 解析 XML。如果我没有将 setforce_feed 设置为 TRUE,SimplePie 甚至不会将其识别为 RSS。 SimplePie 显示的错误消息:

此 XML 文档可能无效 由于无效字符。 XML 错误: 格式不正确(无效令牌)位于 第 1 行,第 1 列

XML 文档的前 2 行是:

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">

知道这里出了什么问题吗?

编辑(用代码更新):

$feed_stomp = new SimplePie();
$feed_stomp->set_feed_url('http://singaporeseen.stomp.com.sg/site/servlet/rss?view=rss&vertical=contentbean%3a3552');
$feed_stomp->force_feed(true);
$feed_stomp->init();
$feed_stomp->handle_content_type();
echo $feed_stomp->error();

I am trying to parse a XML using SimplePie. SimplePie wouldn't even recognize this as RSS if I didn't turn set force_feed to TRUE.
The error message shown by SimplePie:

This XML document is invalid, likely
due to invalid characters. XML error:
Not well-formed (invalid token) at
line 1, column 1

The first 2 lines of the XML document is :

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">

Any idea what goes wrong here?

Edit ( update with code ):

$feed_stomp = new SimplePie();
$feed_stomp->set_feed_url('http://singaporeseen.stomp.com.sg/site/servlet/rss?view=rss&vertical=contentbean%3a3552');
$feed_stomp->force_feed(true);
$feed_stomp->init();
$feed_stomp->handle_content_type();
echo $feed_stomp->error();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

所有深爱都是秘密 2024-09-15 16:54:34

您可能在字符串中留下了 BOM。
请向我们展示您的代码。

You probably left a BOM in the string.
Please show us your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文