Funkce PHP atributy() .
❮ Referenční příručka PHP SimpleXML
Příklad
Vraťte atributy a hodnoty pro prvek XML <body>:
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body date="2014-01-01" type="private">Do
not forget me this weekend!</body>
</note>
XML;
$xml = simplexml_load_string($note);
foreach($xml->body[0]->attributes() as $a => $b)
{
echo $a,'="',$b,"<br>";
}
?>
Definice a použití
Funkce atributy() vrací atributy a hodnoty prvku XML.
Syntax
SimpleXMLElement::attributes(ns, prefix)
Hodnoty parametrů
Parameter | Description |
---|---|
ns | Optional. Specifies a namespace for the retrieved attributes |
prefix | Optional. Specifies TRUE if ns is a prefix and FALSE if ns is a URI. Default is FALSE |
Technické údaje
Návratová hodnota: | Objekt SimpleXMLElement při úspěchu |
---|---|
Verze PHP: | 5,0+ |
❮ Referenční příručka PHP SimpleXML