This function provides the attributes and values defined within an xml tag.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
Optional |
An optional namespace for the retrieved attributes |
|
|
|
Optional |
Default to |
Returns
Type |
Description |
|---|---|
|
Returns a Returns |
Examples
Interpret an XML string
$string = <<<XML
<a>
<foo name="one" game="lonely">1</foo>
</a>
XML;
$xml = simplexml_load_string($string);
foreach($xml->foo[0]->attributes() as $a => $b) {
echo $a,'="',$b,"\"\n";
}
Result:
name="one" game="lonely"

