attributes()

It returns a SimpleXML element’s attributes

Example

<?php
$xml = simplexml_load_file(“test.xml”);
foreach($xml->server[0]->attributes() as $a => $b) {
echo $a;
}
?>

Output

ver

XML

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<web>
<server ver=”5″>Apache</server>
<lan>PHP</lan>
<client>Javascript</client>
</web>