Returns the attributes and values of the XML body element:
<?php$note=<<<XML<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body date="2013-01-01" type= "private">Don't forget me this weekend!</body></note>XML;$xml=simplexml_load_string($note);foreach($xml->body[0]->attributes() as $a => $b) { echo $a,'="',$b,""<br>"; }?>The attributes() function returns the attributes and values of the XML tag.
attributes( ns,is_prefix );
parameter | describe |
---|---|
ns | Optional. Specifies the namespace of the properties to be retrieved. |
is_prefix | Optional. Specifies a boolean value. TRUE if ns is a prefix, FALSE if ns is a URI. The default is FALSE. |
Return value: | If successful, a SimpleXMLElement object is returned. |
---|---|
PHP version: | 5.0.1+ |