Jump to content

get attribute


clankill3r

Recommended Posts

I want to get the url in the [@attributes]

Atm i get the title like this

 

foreach ($xmlTree->channel->item as $item) {
    echo '<p>'.$item->title.'</p>';
}

 

i tried this

    $imageUrl = $item->enclosure->@attributes->url;
    print_r2($imageUrl);

 

but then i get this error:

Parse error: syntax error, unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in /

 

this is the XML:

                    [0] => SimpleXMLElement Object

                        (

                            [title] => #3315: Woord van het jaar: weigerambtenaar, Arabische lente tweede, plaszak derde

                            [link] => http://www.nrc.nl/nieuws/2011/11/26/woord-van-het-jaar-weigerambtenaar/?utm_campaign=rss&utm_source=syndication

                            [pubDate] => Sat, 26 Nov 2011 17:00:55 +0100

                            [guid] => nieuws_153690

                            [description] => SimpleXMLElement Object

                                (

                                )

 

                            [enclosure] => SimpleXMLElement Object

                                (

                                    [@attributes] => Array

                                        (

                                            => http://www.nrc.nl/wp-content/uploads/2011/11/vmBruidstaart5501_63103-586x4801-300x245.jpg

                                            [length] =>

                                            [type] => image/jpeg

                                        )

 

                                )

 

                        )

Link to comment
https://forums.phpfreaks.com/topic/251836-get-attribute/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.