note 104808 deleted from function.xml-set-element-handler by danbrown

From: Date: Fri, 08 Jul 2011 15:09:36 +0000
Subject: note 104808 deleted from function.xml-set-element-handler by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181355@lists.php.net to get a copy of this message
Note Submitter: matthias dot pfafferodt at mapfa dot de ---- My last not is missing but I have an update: * create an array for subelements even if there is only one element * allow recursive elements Only the function startHandle() is updated as listed below: <?php function startHandler($parser, $name, $attrs) { /* Create the new element. */ $element = array(); foreach ($attrs as $key => $value) { $element[XML_ATTR][strtolower($key)] = $value; } /* Add the element to its parent. */ end($this->stack); $k = key($this->stack); $n = strtolower($name); if (!isset($this->stack[$k][XML_SUB][$n])) { /* Create the tag in the parent element. */ $this->stack[$k][XML_SUB][$n] = array(); $this->stack[$k][XML_SUB][$n][] = &$element; } else { /* Add it to the array of tags of this type. */ $this->stack[$k][XML_SUB][$n][] = &$element; } /* Add the element to the stack. Use the current depth to create a unique * name to allow for recursive elements */ $this->stack[sprintf("%s-%d", $n, $this->depth)] = &$element; $this->depth++; return TRUE; } ?>

« previous php.notes (#181355) next »