Rewind to the first element and return the current key (which is the XML tag name of the current element):
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Do not forget me this weekend!</body>
</note>
XML;
$xml = new SimpleXMLIterator($note);
// rewind to the first element
$xml->rewind();
// return current key
var_dump($xml->key());
?>
Run Example »
The key() function returns the current key (which is the XML tag name of the current element).
SimpleXMLIterator::key()
Return Value: | The XML tag name of the current element on success. FALSE otherwise |
---|---|
PHP Version: | 5.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!