note 62817 deleted from ref.xml by didou

From: Date: Sun, 23 Apr 2006 22:58:02 +0000
Subject: note 62817 deleted from ref.xml by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109245@lists.php.net to get a copy of this message
Note Submitter: marco at questar ---- Consider the following XML to be parsed <XML> <MY_DATUM>0</MY_DATUM> </XML> Many of you rely on if(trim($data)) in data handlers of the following type function characterData($parser, $data) { global $stack,$i; if(trim($data)) { $stack[count($stack)-1]['data'] .= $data; } } Unfortunately if $data=='0', that doesn't work at all! The assignment is not executed, therefore the variable is not added to the array, which is wrong (i need to have a variable with value 0) You'll have to use if(count(trim($data))) Beware that !empty(trim($data)) would have the same wrong behaviour This will also be needed if you want to regenerate the xml correctly.

« previous php.notes (#109245) next »