PHP:使用 SimpleXML 访问命名空间 XML
我使用 simplexml() 函数来解析 RSS feed,同时我可以访问 $var->title
到
Feed 摘录 (http://pastebin.com/nN8G78AH):
<item rdf:about="http://newyork.craigslist.org/brk/mcy/1779690213.html">
<title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></title>
<link>http://newyork.craigslist.org/brk/mcy/1779690213.html</link>
<description><![CDATA[
<br>
<br>
2000 KAWASAKI ZX-12R
<br>
<br>
FRONT & REAR RIMS W/FRONT & REAR ROTORS
<br>
<br>
RIMS ARE IN BOLT ON CONDITION .. RIM ARE CHARCOAL BLACK .. ASKING 400.00 OBO
<br>
<br>
CALL 516-216-5768 FOR MORE INFO]]></description>
<dc:date>2010-06-07T13:04:07-04:00</dc:date>
<dc:language>en-us</dc:language>
<dc:rights>Copyright &copy; 2010 craigslist, inc.</dc:rights>
<dc:source>http://newyork.craigslist.org/brk/mcy/1779690213.html</dc:source>
<dc:title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2010-06-07T13:04:07-04:00</dcterms:issued>
</item>
I'm using simplexml() function to parse through RSS feed, while i can access $var->title
to <title>
how do I access <dcterms:issued>
?
Feed excerpt (http://pastebin.com/nN8G78AH):
<item rdf:about="http://newyork.craigslist.org/brk/mcy/1779690213.html">
<title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></title>
<link>http://newyork.craigslist.org/brk/mcy/1779690213.html</link>
<description><![CDATA[
<br>
<br>
2000 KAWASAKI ZX-12R
<br>
<br>
FRONT & REAR RIMS W/FRONT & REAR ROTORS
<br>
<br>
RIMS ARE IN BOLT ON CONDITION .. RIM ARE CHARCOAL BLACK .. ASKING 400.00 OBO
<br>
<br>
CALL 516-216-5768 FOR MORE INFO]]></description>
<dc:date>2010-06-07T13:04:07-04:00</dc:date>
<dc:language>en-us</dc:language>
<dc:rights>Copyright © 2010 craigslist, inc.</dc:rights>
<dc:source>http://newyork.craigslist.org/brk/mcy/1779690213.html</dc:source>
<dc:title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2010-06-07T13:04:07-04:00</dcterms:issued>
</item>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用 SimpleXML 吗?
似乎有一个适合您的解决方案就在这里 。
编辑
为了后代的缘故,在此处复制答案
通过 XML 命名空间访问子级。
Are you using SimpleXML?
A solution for you seems to exist right here.
EDIT
Answer copied here for posterity's sake
Access the children by their XML namespace.