Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP children() Function

PHP children() Function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Example

Find the child nodes of the note node:

Tove Jani Reminder Don't forget me this weekend! XML; $xml=simplexml_load_string($note); foreach ($xml->children() as $child) { echo "Child node: " . $child . "
"; } ?>

Run Example »


Definition and Usage

The children() function finds the child nodes of a specified node.


Syntax

children(

ns,is_prefix

);

Parameters Description
ns Optional. Specifies an XML namespace.
is_prefix Optional. Specifies a boolean. If the value is TRUE, then ns is a prefix. If the value is FALSE, then ns is the namespace URL.

Technical Details

Return Value: Returns a SimpleXMLElement object.
PHP Version: 5.0.1+
PHP Changelog: Added is_prefix parameter was added.

More examples

Example 1

Find the child nodes of the body node:

Tove Jani Reminder Important! Don't forget me this weekend! XML; $xml=simplexml_load_string($note); foreach ($xml->body[0]->children() as $child) { echo "Child node: " . $child . "
"; } ?>

Run Example »


PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual