note 32428 added to function.xpath-new-context

From: Date: Tue, 27 May 2003 15:16:53 +0000
Subject: note 32428 added to function.xpath-new-context
Groups: php.notes 
Request: Send a blank email to php-notes+get-49102@lists.php.net to get a copy of this message
I found a nice function in XML_sql2xml. With it, you can get, easily, the result of a xpath expression. function getXpathValues(&$dom, $expr) { $xpth = $dom->xpath_new_context(); $xnode = xpath_eval($xpth,$expr); if (isset ($xnode->nodeset[0])) { $firstnode = $xnode->nodeset[0]; $children = $firstnode->children(); $value = $children[0]->content; return $value; } else return Null; } Usage : $dom = domxml_open_file('pear.rss'); echo $this->getXpathValues($dom, "//channel/title"); ---- Manual Page -- http://www.php.net/manual/en/function.xpath-new-context.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32428 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32428&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32428&report=yes

« previous php.notes (#49102) next »