From 2346ff037b4319b1d2966f772433df3126e9f76c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 9 Jan 2006 17:44:20 +0000 Subject: [PATCH] Added unify_node() --- xml.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xml.php b/xml.php index 27c627f..65d153e 100644 --- a/xml.php +++ b/xml.php @@ -308,6 +308,27 @@ class XML // assign the attributes to the next newest node $this->attribs =& $this->stack[ count($this->stack) - 1 ]; } + + // ################################################################### + /** + * Unless a node has multiple children, there will not be a numerical + * index for the child node. So this means that if you have variable + * XML structure with some of the same types of nodes having one children + * or multiple children, you'd have different things to parse. If + * you want the node unified (as in, all single-children would be indexed + * numerically, run this function on the node. It works on references. + * + * @access public + * + * @param array The node to int-index + */ + function unify_node(&$node) + { + if (!isset($node[0])) + { + $node = array($node); + } + } } /*=====================================================================*\ -- 2.22.5