SimpleXMLElement->attributes

(no version information, might be only in CVS)

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

Description

SimpleXMLElement simplexml_element->attributes ( [string data] )

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

Nota: SimpleXML ha creado una regla de aƱadir propiedades iterativas a la mayoria de metodos. No se pueden ver usando var_dump() o cualquier cosa que examine objetos.

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

This script will display:

name="one"
game="lonely"

Hosting by: hurra.com
Generated: 2007-01-26 18:00:50