2
我遇到了SimpleXMLIterator
問題,並且通過xml結構降序排列。我打破了它分解成它最簡單的形式爲這個職位:SimpleXMLIterator未顯示子女
<?php
$string = <<<'XML'
<test>
<group>
<script>
</script>
</group>
</test>
XML;
$iterator = new SimpleXMLIterator($string);
for($iterator->rewind() ; $iterator->valid() ; $iterator->next()){
echo $iterator->key() . "<br>";
}
我希望,上面的代碼將輸出:
group
script
但是當我運行它,它只是輸出group
。
當我移動的XML使組和腳本是兄弟:
<?php
$string = <<<'XML'
<test>
<group>
</group>
<script>
</script>
</test>
XML;
$iterator = new SimpleXMLIterator($string);
for($iterator->rewind() ; $iterator->valid() ; $iterator->next()){
echo $iterator->key();
}
我拿到團體和腳本呼應了。
我一直在閱讀迭代器的文檔,我沒有看到任何說它不會降到兒童。我誤解了這個工具嗎?
完美,這正是我需要的。謝謝! – 2014-10-30 03:12:34
@ChrisSchmitz很高興這有幫助 – Ghost 2014-10-30 03:12:58