PHP SimpleXML问题 [英] PHP SimpleXML issue

查看:71
本文介绍了PHP SimpleXML问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用curl获取xml流。我已经收到了curl字符串,但是在使用SimpleXML解析xmlstream时遇到了麻烦。我使用的网址是 http://www.google.com/books/feeds/volumes/ fR4vqfywNlgC
,似乎忽略了包含 dc的部分。为什么?

I'm trying to get an xml stream by using curl. I've recieved the string with curl but I'm having troubles parsing the xmlstream with SimpleXML. The url im using is http://www.google.com/books/feeds/volumes/fR4vqfywNlgC and it seems to be ignoring the parts containing "dc". Why?

推荐答案

都柏林核心数据(至少在这种情况下,我假设这就是DC前缀的意思)自己的名称空间。检索这些元素时,需要引用该名称空间。可以使用 儿童方法来完成。

The dublin core data (at least, I'm assuming that's what the DC prefix means in this case) uses its own namespace. You need to refer to that namespace when retrieving these elements. This can be done using the 'children' method.

示例:

$sxml = simplexml_load_string($xml);
$dcData = $sxml->children('dc', TRUE);
echo (string)$dcData->creator;

可以在此处找到详细介绍问题和解决方案的文章/帖子。

An article/posting detailing the problem and solution can be found here.

http://blogs.sitepoint.com/simplexml-and-名称空间/

这篇关于PHP SimpleXML问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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