suche nach in der

SimpleXMLElement::children> <SimpleXMLElement::asXML
Last updated: Fri, 25 May 2012

view this page in

SimpleXMLElement::attributes

(PHP 5 >= 5.0.1)

SimpleXMLElement::attributesIdentifies an element's attributes

Beschreibung

public SimpleXMLElement SimpleXMLElement::attributes ([ string $ns = NULL [, bool $is_prefix = false ]] )

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

Hinweis: SimpleXML definiert für die meisten Methoden Regeln für das Hinzufügen von iterativen Eigenschaften. Diese können weder mit var_dump() oder auf andere Weise angezeigt werden.

Parameter-Liste

ns

An optional namespace for the retrieved attributes

is_prefix

Default to FALSE

Rückgabewerte

Returns a SimpleXMLElement object that can be iterated over to loop through the attributes on the tag.

Returns NULL if called on a SimpleXMLElement object that already represents an attribute and not a tag.

Beispiele

Beispiel #1 Interpret an XML string

<?php
$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";
}
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

name="one"
game="lonely"

Siehe auch



add a note add a note User Contributed Notes
SimpleXMLElement::attributes
There are no user contributed notes for this page.

SimpleXMLElement::children> <SimpleXMLElement::asXML
Last updated: Fri, 25 May 2012