Simple XML - Dealing With Colons In Nodes

前端 未结 4 484
悲&欢浪女
悲&欢浪女 2020-11-22 14:40

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)

4条回答
  •  借酒劲吻你
    2020-11-22 14:59

    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; 
    }

提交回复
热议问题