开发者

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

开发者 https://www.devze.com 2023-03-16 14:02 出处:网络
How do I get blip:picture and blip:embedUrl from the following XML: <rss xmlns:blip=\"http://blip.tv/dtd/blip/1.0\">

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

精彩评论

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