children()"HREF="function.simplexml-element-children.html"> Podręcznik PHP Poprzedni Następny (no version i..."/>
Forum und email
SimpleXMLElement->attributes()

SimpleXMLElement->attributes()

(no version information, might be only in CVS)

SimpleXMLElement->attributes() -- Identifies an element's attributes

Opis

class SimpleXMLElement {

SimpleXMLElement attributes ( [string ns [, bool is_prefix]] )

}

This function provides the attributes and values defined within an xml tag.

Notatka: 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.

Parametry

ns

An optional namespace for the retrieved attributes

is_prefix

Default to FALSE

Zwracane wartości

Przykłady

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"