note 55527 added to function.xml-set-character-data-handler
| From: | benatremovethisemediastudiosdotcom at osu1 dot php dot net | Date: | Fri, 05 Aug 2005 22:53:59 +0000 |
| Subject: | note 55527 added to function.xml-set-character-data-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93146@lists.php.net to get a copy of this message | ||
I too love the undocumented "splitting" functionality :-p.
Rather than concatinating the data based on whether or not the current tag name has changed from the
previous tag name I suggest always concatinating like the following with the $catData variable being
unset in the endElement function:
<?php
function endElement ($parser, $data) {
global $catData;
// Because we are at an element end we know any splitting is finished
unset($GLOBALS['catData']);
}
function characterData ($parser, $data) {
global $catData;
// Concatinate data in case splitting is taking place
$catData.=$data;
}
?>
This got me around a problem with data like the following where, because characterData is not called
for empty tags, the previous and current tag names were the same even though splitting was not
taking place.
<companydept>
<companydeptID></companydeptID>
<companyID>1</companyID>
<companydeptName></companydeptName>
</companydept>
<companydept>
<companydeptID></companydeptID>
<companyID>2</companyID>
<companydeptName></companydeptName>
</companydept>
<companydept>
<companydeptID></companydeptID>
<companyID>3</companyID>
<companydeptName></companydeptName>
</companydept>
----
Manual Page -- http://www.php.net/manual/en/function.xml-set-character-data-handler.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55527
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55527&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55527&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55527&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55527&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55527&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55527&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55527&report=yes
Search -- http://master.php.net/manage/user-notes.php