DomNode::node_name> <DomNode::last_child
Last updated: Fri, 24 Feb 2012

DomNode::next_sibling

(PHP 4 >= 4.1.0)

DomNode::next_sibling Returns the next sibling of node

Descrição

domelement DomNode::next_sibling ( void )

This function returns the next sibling of the current node. If there is no next sibling it returns FALSE (< 4.3) or null (>= 4.3). You can use this function to iterate over all children of a node as shown in the example.

Exemplo #1 Iterate over children

<?php
include("example.inc");

if (!
$dom domxml_open_mem($xmlstr)) {
  echo 
"Error while parsing the document\n";
  exit;
}

$elements $dom->get_elements_by_tagname("tbody");
$element $elements[0];
$child $element->first_child();

while (
$child) {
   
print_r($child);
   
$child $child->next_sibling();
}
?>

See also domnode_previous_sibling().



User Contributed Notes
DomNode::next_sibling
Jon
02-Sep-2007 03:15
filip dot gorny at gmail dot com: There is no bug in the code, that is the correct function name.  Go to http://php.net/get_elements_by_tag_name and click the first link for domdocument_get_elements_by_tagname (I couldn't paste the direct link here because of restrictions for long lines that can't word wrap)
filip dot gorny at gmail dot com
18-Dec-2005 06:57
There is a simply bug in the example.
We use getElementsByTagName, no get_elements_by_tag_name.

Nemis

DomNode::node_name> <DomNode::last_child
Last updated: Fri, 24 Feb 2012