children
返回指定節點的子節點。
children()
函數用於查找指定節點的子節點。
查找注::
<? php $ note = <<< xml <note> <to>喬治</to> <來自> John </from> <Theed>提醒</heading> <身體>不要忘記會議! </body> </note> xml ; $ xml = simplexml_load_string ( $ note ) ; foreach ( $ xml- > children ( )作為$ child ) { 迴聲“兒童節點:” 。 $孩子。 “ <br>” ; } ? >
運行實例
查找身體::
<? php $ note = <<< xml <note> <to>喬治</to> <來自> John </from> <Theed>提醒</heading> <body> <span>很重要! </span>不要忘記我這個週末! </body> </note> xml ; $ xml = simplexml_load_string ( $ note ) ; foreach ( $ xml- >正文[ 0 ] - >兒童( )作為$ child ) { 迴聲“兒童節點:” 。 $孩子。 “ <br>” ; } ? >
運行實例
SimpleXMLElement :: children ( ns , prefix )
參數 | 描述 |
---|---|
ns | 可選。指定XML 命名空間。 |
prefix |
可選。布爾值。如果為TRUE, ns被視為前綴;如果為FALSE, ns被視為命名空間URL。 默認為FALSE。 |