简单的XML-处理节点中的冒号 [英] Simple XML - Dealing With Colons In Nodes

查看:279
本文介绍了简单的XML-处理节点中的冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Flickr中读取RSS提要,但是它具有一些不能被简单XML读取的节点(media:thumbnailflickr:profile等).

I'm trying to read an RSS feed from Flickr but it has some nodes which are not readable by Simple XML (media:thumbnail, flickr:profile, and so on).

如何解决这个问题?当我查看DOM文档时,我的头很痛.所以我想避免这种情况,因为我不想学习.

How do I get round this? My head hurts when I look at the documentation for the DOM. So I'd like to avoid it as I don't want to learn.

我正在尝试获取缩略图.

I'm trying to get the thumbnail by the way.

推荐答案

该解决方案在

The solution is explained in this nice article. You need the children() method for accessing XML elements which contain a namespace. This code snippet is quoted from the article:

$feed = simplexml_load_file('http://www.sitepoint.com/recent.rdf'); 
foreach ($feed->item as $item) { 
    $ns_dc = $item->children('http://purl.org/dc/elements/1.1/'); 
    echo $ns_dc->date; 
}

这篇关于简单的XML-处理节点中的冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆