<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xmlIterator = new SimpleXMLIterator($note);
for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) {
echo "<pre>";
echo var_dump($xmlIterator->key());
}
?>
out put :
string(2) "to"
string(4) "from"
string(7) "heading"
string(4) "body"