gpt4 book ai didi

用于将 xml 解析为不带命名空间的节点的数组的 PHP 函数

转载 作者:行者123 更新时间:2023-12-04 17:05:03 25 4
gpt4 key购买 nike

我正在尝试解析使用格式良好的 Web 评论 api 的 rss 提要,并且在提取包含命名空间的 XML 部分时遇到了一些问题。我在这里检查:

PHP parsing XML file with and without namespaces

但似乎他的解决方案更多的是针对一个特定的命名空间。这是我的 XML:

 <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>Some TITLE</title>
<link>http://www.somelink.com</link>
<description>Make it happen.</description>
<dc:language />
<generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator>
<item>
<title>Blah blah blah</title>
<link>http://www.somelink.com</link>
<pubDate>Wed, 21 Jul 2010 16:30:00 GMT</pubDate>
<guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9612038</guid>
<dc:creator>Chris Pendleton</dc:creator>
<slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">

我曾尝试将几个对象用于我通常用于解析 XML 的数组函数,但它们忽略了所有包含 namespace 的节点。建议?我真正需要的只是获取每个节点的对象。

TIA

最佳答案

你试过 XMLReader 吗?
http://php.net/manual/en/book.xmlreader.php

关于用于将 xml 解析为不带命名空间的节点的数组的 PHP 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3365666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com