I play arround almost all day to get the attributes of an xml element, which is a namespace. XML part: ...
<item> <title>name</title> <link>link</link> <media:thumbnail url="url" height="133" width="200" /> </item>
... I managed to get the name and link with the following script:
$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);
After printing $ gThumb, I get:
SimpleXMLElement Object ( [@attributes] => Array ( [url] => url [height] => 133 [width] => 200 ) )
And I need to get the url from the attribute. I would be very happy to receive any help.
source share