PHP children() Function

Description

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

Syntax

PHP children() Function has the following syntax.

children(ns,is_prefix);

Parameter

ParameterIs requiredDescription
nsOptional.An XML namespace
is_prefixOptional.If TRUE, ns is regarded as a prefix. If FALSE, ns is regarded as a namespace URL

Return

Returns a SimpleXMLElement object

Example

Find the children of the note node:


<?php/*from   w ww.java2  s.  c o m*/
$note=<<<XML
<book>
    <name>PHP</name>
    <name>Java</name>
</book>
XML;

$xml=simplexml_load_string($note);
foreach ($xml->children() as $child){
  echo "Child node: " . $child . "\n";
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions