DomNode::child_nodes

(PHP 4 >= 4.1.0)

DomNode::child_nodes Returns children of node

Описание

array DomNode::child_nodes ( void )

Returns all children of the node.

See also domnode_next_sibling(), and domnode_previous_sibling().

[an error occurred while processing the directive]

Коментарии

I was using child_nodes and if I have a node like this.
<node>
    <child/>
</node>

the node <node> have two children: one the "    " spaces that appear as #text on php and <child/>. Is that normal? I think node has just one child <child/>
2002-08-27 21:36:42
http://php5.kiev.ua/manual/ru/function.domnode-child-nodes.html
To answer hrosas)at(linuxmail)dot(org.

<node>
<child/>
</node>

<node> has 3 children. 
1. whitespace between <node> and <child/>
2. <child/>
3. whitespace between <child/> and </node>

The whitespace is treated like text. To avoid this remove all whitespace.

<node><child/></node>

This can get hard to read, but correct.

But, you can tell some programs to ignore the whitespace, so it remains easy to read.

Jon Sprague
2002-09-10 19:54:21
http://php5.kiev.ua/manual/ru/function.domnode-child-nodes.html
A better way to check for Text Child nodes (PHP 4.3.0)

    if ($childnode->node_type() == XML_TEXT_NODE)
    {
        echo "<br/>This item is a text node.";
    }
    else
    {
        echo "<br/>This item is not a text node.";
    }

You may want to look at DomElement->is_blank_node() as well.
2003-03-09 19:32:45
http://php5.kiev.ua/manual/ru/function.domnode-child-nodes.html
to avoid the "#text" what you can simply do without changing your xml file, is:

if($item->nodeName != "#text"){
// do your code.
}
2008-04-30 05:57:06
http://php5.kiev.ua/manual/ru/function.domnode-child-nodes.html

    Поддержать сайт на родительском проекте КГБ