PHP hasChildren() 함수
예시
현재 요소에 자식이 있는지 여부를 확인합니다(있는 경우). 현재 요소를 출력합니다.
<?php
$bookxml = <<<XML
<bookstore>
<book>
<title>Everyday Italian</title>
<author>Giada De
Laurentiis</author>
</book>
<book>
<title>Harry Potter</title>
<author>J K.
Rowling</author>
</book>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
</book>
</bookstore>
XML;
$xml = new SimpleXMLIterator($bookxml);
for( $xml->rewind(); $xml->valid(); $xml->next() ) {
if($xml->hasChildren())
{
var_dump($xml->current());
echo
"<br>";
}
}
?>
정의 및 사용
hasChildren() 함수는 현재 요소에 자식이 있는지 확인합니다.
통사론
SimpleXMLIterator::hasChildren()
기술적 세부 사항
반환 값: | 현재 요소에 자식이 있으면 TRUE입니다. 그렇지 않으면 거짓 |
---|---|
PHP 버전: | 5.0+ |
❮ PHP SimpleXML 참조