SimpleXMLElement->attributes()
(PHP 5 >= 5.0.1)
SimpleXMLElement->attributes() — Identifies an element's attributes
Descrierea
SimpleXMLElement
SimpleXMLElement attributes
([ string $ns
[, bool $is_prefix
]] )
This function provides the attributes and values defined within an xml tag.
Notă: SimpleXML a creat o regulă de a adăuga proprietăţi iterative la majoritatea metodelor. Ele nu pot fi vizualizate cu ajutorul var_dump() sau orice altceva ce poate examina obiecte.
Parametri
- ns
-
An optional namespace for the retrieved attributes
- is_prefix
-
Default to FALSE
Valorile întroarse
Exemple
Example#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";
}
?>
Exemplul de mai sus va afiÅŸa:
name="one" game="lonely"