cvs: pear /XML_XPath/XPath common.php
| From: | Daniel Allen | Date: | Wed, 05 Jun 2002 07:50:31 +0000 |
| Subject: | cvs: pear /XML_XPath/XPath common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4417@lists.php.net to get a copy of this message | ||
dallen Wed Jun 5 03:50:31 2002 EDT
Modified files:
/pear/XML_XPath/XPath common.php
Log:
@ added childNodes() which takes the current pointer and returns all of the non-blank (if set)
children as an xml_xpath_result object so that the result object functions can be used to
step through the results...one disadvantage right now is that since it is not an actually xpath
query, I can't resort the results, so that result function will be broken when the result
object
is generated in this manner...hang in there, I am working on this...
Index: pear/XML_XPath/XPath/common.php
diff -u pear/XML_XPath/XPath/common.php:1.12 pear/XML_XPath/XPath/common.php:1.13
--- pear/XML_XPath/XPath/common.php:1.12 Fri May 24 01:05:16 2002
+++ pear/XML_XPath/XPath/common.php Wed Jun 5 03:50:31 2002
@@ -17,7 +17,7 @@
// | Authors: Dan Allen <dan@mojavelinux.com> |
// +----------------------------------------------------------------------+
-// $Id: common.php,v 1.12 2002/05/24 05:05:16 dallen Exp $
+// $Id: common.php,v 1.13 2002/06/05 07:50:31 dallen Exp $
// }}}
// {{{ description
@@ -249,6 +249,45 @@
else {
return false;
}
+ }
+
+ // }}}
+ // {{{ object childNodes()
+
+ /**
+ * Retrieves the child nodes from the element node as an XML_XPath_result object
+ *
+ * Similar to an xpath query, this function will grab all the first descendant child
+ * nodes of the element node at the current position and will create an XML_XPath_result
+ * object of type nodeset with each of the child nodes as the nodes.
+ *
+ * @param string $in_xpathQuery (optional) quick xpath query
+ * @param boolean $in_movePointer (optional) move the internal pointer with quick xpath query
+ *
+ * @access public
+ * @return object XML_XPath_result object of type nodeset
+ * [!] important note: since we had to hack the result object a bit, you cannot sort the
+ * result object when generated in this manner right now [!]
+ */
+ function &childNodes($in_xpathQuery = null, $in_movePointer = false)
+ {
+ if (XML_XPath::isError($result = $this->_quick_evaluate_init($in_xpathQuery,
$in_movePointer, array(XML_ELEMENT_NODE)))) {
+ return $result;
+ }
+
+ // since we can't do an actual xpath query, we need to create a pseudo xpath result
+ $xpathObj = new StdClass();
+ $xpathObj->type = XPATH_NODESET;
+ foreach($this->pointer->child_nodes() as $childNode) {
+ // if this is a blank node and we are skipping blank nodes...skip to next child
+ if ($childNode->is_blank_node() && $this->skipBlanks) {
+ continue;
+ }
+ $xpathObj->nodeset[] = $childNode;
+ }
+ $resultObj =& new XML_XPath_result($xpathObj, null, $this->xml, $this->ctx);
+ $this->_quick_evaluate_shutdown($in_xpathQuery, $in_movePointer);
+ return $resultObj;
}
// }}}