0
xml名稱空間屬性解析如何使用PHP解析「media:text」和「media:credit」和「media:content」屬性值。在以下xml文件中使用php
<item>
<title>Tom Tremendous: Brady rallies Patriots over Saints</title>
<description>
<p>With Gillette Stadium nearly half-empty, the fans figuring the New England Patriots had thrown away their last chance, Tom Brady delivered a drive to savor Sunday.</p>
</description>
<link>
http://news.yahoo.com/tom-tremendous-brady-rallies-patriots-over-saints-011721864--spt.html
</link>
<pubDate>Sun, 13 Oct 2013 21:17:21 -0400</pubDate>
<source url="http://www.ap.org/">Associated Press</source>
<guid isPermaLink="false">
tom-tremendous-brady-rallies-patriots-over-saints-011721864--spt
</guid>
<media:content url="http://l2.yimg.com/bt/api/res/1.2/J7A0cSqro3niTyUB7bbLJQ--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTg2O3E9NzU7dz0xMzA-/http://media.zenfs.com/en_us/News/ap_webfeeds/183a1f218a441f22400f6a7067003712.jpg" type="image/jpeg" width="130" height="86"/>
<media:text type="html">
</media:text>
<media:credit role="publishing company"/>
</item>
我解析 「http://news.yahoo.com/rss/sports」 ......我可以獲取其他數據,<?PHP $ XML =使用simplexml_load_file('HTTP ://news.yahoo.com/rss/sports'); $ sitemap = $ xml-> channel; ($ sitemap-> children()as $ child){ echo $ child-> getName()。「」; foreach($ child-> children()as $ subchild){ echo「--->」。$ subchild-> getName()。「:」。$ subchild。「」; } } ?>但我不能得到如何獲得標籤.. –