Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP attributes() Function

PHP attributes() Function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Example

Return the attributes and values of the body element of the XML:

Tove Jani Reminder Don't forget me this weekend! XML; $xml=simplexml_load_string($note); foreach($xml->body[0]->attributes() as $a => $b) { echo $a,'="',$b,""
"; } ?>

Run Example »


Definition and Usage

The attributes() function returns the attributes and values of an XML tag.


Syntax

attributes(

ns,is_prefix

);

Parameters Description
ns Optional. Specifies the namespace of the attributes to be retrieved.
is_prefix Optional. Specifies a boolean. If ns is a prefix then TRUE, if ns is a URI then FALSE. Default is FALSE.

Technical Details

Return Value: Returns a SimpleXMLElement object on success.
PHP Version: 5.0.1+

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual