SimpleXMLElement
PHP Manual

SimpleXMLElement::attributes

(PHP 5 >= 5.0.1)

SimpleXMLElement::attributesIdentifies an element's attributes

Descrição

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

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

Nota: SimpleXML tem uma regra quando do acréscimo de propriedades iterarivas na maioria dos métodos. Eles não podem ser visualizados com var_dump() nem nada que possa visualizar objetos.

Parâmetros

ns

An optional namespace for the retrieved attributes

is_prefix

Default to FALSE

Valor Retornado

Exemplos

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

O exemplo acima irá imprimir:

name="one"
game="lonely"


SimpleXMLElement
PHP Manual