PHP - SimpleXMLElement - 解析im:image

时间:2011-10-13 18:53:30

标签: php simplexml xml-namespaces

如何提取im:image元素。例如,我可以这样做:

$feed=file_get_contents($url);
$xml = new SimpleXMLElement($feed);
$title = $xml->entry[0]->title;
$html = $xml->entry[0]->content;

但我无法得到这个:

$img = $xml->entry[0]->im;

我如何定位?我也愿意使用DOMDocument()。

编辑:

<entry>
  <im:image height="55">
    http://foo.com/foo.jpg
  </im:image>
</entry>

1 个答案:

答案 0 :(得分:0)

im只是一个命名空间。你想要'image'元素,而不是im - Dmitri Snytkine 20小时前

是的,这是真的,也是我需要的线索。

相关问题