SimpleXMLIterator::getChildren
(PHP 5, PHP 7)
SimpleXMLIterator::getChildren — 現在の要素の子要素を返す
説明
public SimpleXMLIterator::getChildren ( ) : SimpleXMLIterator
このメソッドは、現在の SimpleXMLIterator 要素の子要素を含む SimpleXMLIterator オブジェクトを返します。
パラメータ
この関数にはパラメータはありません。
例
例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