note 89771 deleted from class.domxpath by danbrown

From: Date: Thu, 13 May 2010 13:43:10 +0000
Subject: note 89771 deleted from class.domxpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169210@lists.php.net to get a copy of this message
Note Submitter: ahsdg at NOSPAM dot pochta dot ru ---- For more then one search this function will be helpfull: <?php class xpathExtension{ public static function getNodes($domDoc, $xpathString) { $xp = new DOMXPath($domDoc); $xp->registerNamespace('x', 'http://www.w3.org/1999/xhtml'); $xp->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml'); $xp->registerNamespace('i18n', 'http://apache.org/cocoon/i18n/2.1'); $ret = array(); $nodes = $xp->query($xpathString); foreach ($nodes as $node) { array_push($ret, $node); } return $ret; } } $domDoc = new DOMDocument(); $domDoc->load("xmlFile.xml"); $xpathString = "//html/body/*[@class='text']"; $domNodeList = xpathExtension::getNodes($domDoc, $xpathString); foreach($domNodeList as $domNode){ echo $domNode->nodeName; } ?> Thanks to: https://svn.liip.ch/repos/public/okapi/core/trunk/inc/api/helpers/ xpath.php

« previous php.notes (#169210) next »