4
我几乎整天都在玩arround,以获取xml项的属性,它是名称空间。 XML的部分: ...带命名空间和属性的XML PHP for PHP
<item>
<title>name</title>
<link>link</link>
<media:thumbnail url="url" height="133" width="200" />
</item>
... 我设法得到的标题和链接与下面的脚本:
$z = new XMLReader;
$z->open($gLink);
$doc = new DOMDocument;
while ($z->read() && $z->name !== 'item');
$node = simplexml_import_dom($doc->importNode($z->expand(), true));
$gTitle = $node->title;
$gLink = $node->link;
$gThumb = $node->children('media', true)->thumbnail->children();
print_r($gThumb);
打印$ gThumb的之后,我得到:
SimpleXMLElement Object ([@attributes] => Array ([url] => url [height] => 133 [width] => 200))
而我需要得到的是来自属性的网址。我很乐意得到任何帮助。
赌注是什么,因为它是从一些RSS采取 – minijus 2011-04-15 16:52:04
可能重复我不能修改XML [如何获得与SimpleXML的属性?(HTTP://计算器.com/questions/3410520/how-to-get-an-attribute-with-simplexml) – Gordon 2011-04-15 16:56:12