开发者

How do I parse this XML file from Blip.tv?

How do I get blip:picture and blip:embedUrl from the following XML:

<rss xmlns:blip="http://blip.tv/dtd/blip/1.0">
  <channel>
    <item>
      <blip:picture>http://blip.tv/skin/blipnew/placeholder_user.gif</blip:picture>
      <blip:embedUrl type="application/x-shockwave-flash">http://blip.tv/play/gvsIgeevJAI</blip:embedUrl>
    </item
  </channel>
&l开发者_开发问答t;/rss>

The full XML feed is here:

http://blip.tv/rss/3790656

Solution:

$xml = new SimpleXMLElement($result);

$thumbnail = $xml->xpath('channel/item/blip:picture');

$thumbnail = $thumbnail[0];


$xml is a SimpleXMLElement, and you can use the xpath function to retrieve your information.

$picture  = $xml->xpath('item/blip:picture');
$embedUrl = $xml->xpath('item/blip:embedUrl');


By Reading The Fancy Manual.

[edit, in response to yours]

There is no such thing as custom tags in XML. Or actually, they all are custom elements. There are no fixed tags, unlike in XHTML, which is a special structure, describing HTML-specific elements in an XML structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜