(PHP 5 >= 5.0.1)
SimpleXMLElement::attributes — Identifies an element's attributes
This function provides the attributes and values defined within an xml tag.
Informacja: W SimpleXML wprowadzono zasadę dodawania pól iteracyjnych dla większości metod. Nie mogą być one przeglądane przez var_dump() ani przez nic innego co bada obiekty.
An optional namespace for the retrieved attributes
Default to FALSE
Przykład #1 Interpret an XML string
<?php
$string = <<<XML
<a xmlns:b>
<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";
}
?>
Powyższy przykład wyświetli:
name="one" game="lonely"