【问题标题】:PHP -- SimpleXMLElement -- parsing im:imagePHP -- SimpleXMLElement -- 解析 im:image
【发布时间】:2011-10-13 18:53:30
【问题描述】:

如何提取 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>

【问题讨论】:

  • 你的 XML 是.... rss?
  • im 只是一个命名空间。你想要 'image' 元素,而不是 im
  • 谢谢 Dmitri,这正是我需要的线索。

标签: php simplexml xml-namespaces


【解决方案1】:

im 只是一个命名空间。你想要“图像”元素,而不是我——Dmitri Snytkine 20 小时前

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-26
    • 1970-01-01
    • 1970-01-01
    • 2018-03-19
    • 2015-09-14
    • 2015-08-04
    • 1970-01-01
    相关资源
    最近更新 更多