note 47748 added to ref.dom

From: Date: Sat, 27 Nov 2004 23:12:46 +0000
Subject: note 47748 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-81106@lists.php.net to get a copy of this message
If you have two nodes in a HTML DOM and you want to get all text nodes between them, you can do someting like this: <?php // Start node; e.g.: $n=$dom->lastChild->previousSibling->firstChild->nextSibling; // End node, e.g: $e=$dom->lastChild; while (true) { if ($n->nodeType===XML_TEXT_NODE) { // Add " && !$up" if it's not XML_TEXT_NODE echo $n->nodeValue;} if ($n->isSameNode($e)) { break;} if (($n->firstChild !== NULL) && !$up) { $n=$n->firstChild;} elseif ($n->nextSibling !== NULL) { $up=false; $n=$n->nextSibling;} elseif ($n->parentNode !== NULL) { $up=true; $n=$n->parentNode;} else { break;}} ?> ---- Manual Page -- http://www.php.net/manual/en/ref.dom.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47748 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47748&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47748&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47748&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47748&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47748&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47748&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47748&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81106) next »