SimpleXML SimpleXMLIterator::getChildren

(PHP 5, PHP 7, PHP 8)

SimpleXMLIterator::getChildren — 현재 요소의 하위 요소를 반환합니다.


설명

public SimpleXMLIterator::getChildren(): SimpleXMLIterator

이 메서드는 현재 SimpleXMLIterator 요소의 하위 요소를 포함하는 SimpleXMLIterator 객체를 반환합니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

현재 요소의 하위 요소를 포함하는 SimpleXMLIterator 개체를 반환합니다.


Examples

예제 #1 현재 요소의 하위 요소를 반환

                  
<?php
$xml = <<<XML
<books>
    <book>
        <title>PHP Basics</title>
        <author>Jim Smith</author>
    </book>
    <book>XML basics</book>
</books>
XML;

$xmlIterator = new SimpleXMLIterator($xml);
for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) {
    foreach($xmlIterator->getChildren() as $name => $data) {
    echo "The $name is '$data' from the class " . get_class($data) . "\n";
    }
}
?>
                  
                

위의 예는 다음을 출력합니다.

The title is 'PHP Basics' from the class SimpleXMLIterator
The author is 'Jim Smith' from the class SimpleXMLIterator