note 104808 added to function.xml-set-element-handler
| From: | matthias dot pfafferodt at mapfa dot de | Date: | Fri, 08 Jul 2011 09:39:23 +0000 |
| Subject: | note 104808 added to function.xml-set-element-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181348@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 217.160.235.204
Probable Submitter: 198.36.86.81
----
Manual Page -- http://www.php.net/manual/en/function.xml-set-element-handler.php
Edit -- https://master.php.net/note/edit/104808
Del: integrated -- https://master.php.net/note/delete/104808/integrated
Del: useless -- https://master.php.net/note/delete/104808/useless
Del: bad code -- https://master.php.net/note/delete/104808/bad+code
Del: spam -- https://master.php.net/note/delete/104808/spam
Del: non-english -- https://master.php.net/note/delete/104808/non-english
Del: in docs -- https://master.php.net/note/delete/104808/in+docs
Del: other reasons-- https://master.php.net/note/delete/104808
Reject -- https://master.php.net/note/reject/104808
Search -- https://master.php.net/manage/user-notes.php