PHP children()函數(shù)講解
PHP children() 函數(shù)
實(shí)例
查找 note 節(jié)點(diǎn)的子節(jié)點(diǎn):
<?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é)點(diǎn)的子節(jié)點(diǎn)。
語(yǔ)法
children( _ns,is_prefix_ );


實(shí)例 1
查找 body 節(jié)點(diǎn)的子節(jié)點(diǎn):
<?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é)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
- PHP addcslashes()函數(shù)講解
- PHP addslashes()函數(shù)講解
- PHP simplexml_load_string()函數(shù)實(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)文章
不用GD庫(kù)生成當(dāng)前時(shí)間的PNG格式圖象的程序
不用GD庫(kù)生成當(dāng)前時(shí)間的PNG格式圖象的程序...2006-10-10
php面向?qū)ο笕ヂ?(十七) 自動(dòng)加載類
多開(kāi)發(fā)者寫面向?qū)ο蟮膽?yīng)用程序時(shí),對(duì)每個(gè)類的定義建立一個(gè)PHP 源文件。一個(gè)很大的煩惱是不得不在每個(gè)腳本(每個(gè)類一個(gè)文件)開(kāi)頭寫一個(gè)長(zhǎng)長(zhǎng)的包含文件的列表。2009-09-09
Apache, PHP在Windows 9x/NT下的安裝與配置 (二)
Apache, PHP在Windows 9x/NT下的安裝與配置 (二)...2006-10-10

