PHP children()函數(shù)講解
更新時間:2019年02月03日 09:53:27 作者:php參考手冊
今天小編就為大家分享一篇關(guān)于PHP children()函數(shù)講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
PHP children() 函數(shù)
實例
查找 note 節(jié)點的子節(jié)點:
<?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XML; $xml=simplexml_load_string($note); foreach ($xml->children() as $child) { echo "Child node: " . $child . "<br>"; } ?>
定義和用法
children()
函數(shù)查找指定節(jié)點的子節(jié)點。
語法
children( _ns,is_prefix_ );
實例 1
查找 body 節(jié)點的子節(jié)點:
<?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body><span>Important!</span> Don't forget me this weekend!</body> </note> XML; $xml=simplexml_load_string($note); foreach ($xml->body[0]->children() as $child) { echo "Child node: " . $child . "<br>"; } ?>
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
您可能感興趣的文章:
- PHP addcslashes()函數(shù)講解
- PHP addslashes()函數(shù)講解
- PHP simplexml_load_string()函數(shù)實例講解
- PHP simplexml_load_file()函數(shù)講解
- PHP simplexml_import_dom()函數(shù)講解
- PHP count()函數(shù)講解
- PHP getDocNamespaces()函數(shù)講解
- PHP getName()函數(shù)講解
- PHP getNamespaces()函數(shù)講解
- PHP registerXPathNamespace()函數(shù)講解
- PHP xpath()函數(shù)講解
相關(guān)文章
php學(xué)習(xí)筆記 面向?qū)ο笾衃接口]與[多態(tài)性]的應(yīng)用
接口是一種特殊的抽象類,抽象類又是一種特殊的類2011-06-06