SimpleXMLElement Object(
[ImageFormat] => SimpleXMLElement Object(
[@attributes] => Array(
[DimensionCategory] => small
[Title] => extra
)
[URL] => link..
)
)
Asked
Active
Viewed 565 times
-1
-
3You need to explain where you got the output from! – user9876 Aug 31 '11 at 11:42
-
Ok! This is an output generated by print_r() function. – Raphael Aug 31 '11 at 11:45
-
Maybe it's just the name of the class-member… – feeela Aug 31 '11 at 11:46
-
Why haven't member "URL" got the symbol "@"? – Raphael Aug 31 '11 at 11:49
-
URL is an element node, while the `@attributes` ... the name already telling you is attribute – ajreal Aug 31 '11 at 11:56
-
possible duplicate of [Accessing @attribute from SimpleXML](http://stackoverflow.com/questions/1652128/accessing-attribute-from-simplexml) – hakre Jul 21 '13 at 09:27
3 Answers
2
@attributes
is derived from this
<ImageFormat DimensionCategory="small" Title="extra">
<URL />
</ImageFormat>
in another word, is attributes of a given element

ajreal
- 46,720
- 11
- 89
- 119
1
It's simply part of the member name:
echo $xml->ImageFormat->{'@attributes'}['Title'];
You should use the attributes()
method of the SimpleXMLElement
class to access the attributes of an XML elment.

knittl
- 246,190
- 53
- 318
- 364
1
As knittl stated, it's just a member name. As a note: to access attributes in a SimpleXML node, instead of doing:
echo $xml->ImageFormat->{'@attributes'}['Title'];
One would do:
echo $xml->ImageFormat['Title'];

Community
- 1
- 1