【发布时间】:2010-07-29 18:10:11
【问题描述】:
我正在尝试解析使用格式良好的 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 的函数,但它们忽略了所有包含命名空间的节点。建议?我真正需要的只是获取每个节点的对象。
TIA
【问题讨论】:
标签: php xml namespaces