SimpleXMLIterator::key

(PHP 5, PHP 7, PHP 8)

SimpleXMLIterator::keyRetorna a chave atual do SimpleXML

Descrição

SimpleXMLIterator::key ( ) : mixed
Aviso

Esta função não está documentada; somente a lista de argumentos está disponível.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

A chave atual do SimpleXML.

add a note add a note

User Contributed Notes 1 note

up
3
bmafzallmahmud at gmail dot com
6 years ago
<?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"
To Top