note 62817 added to ref.xml

From: Date: Fri, 10 Mar 2006 10:51:58 +0000
Subject: note 62817 added to ref.xml
Groups: php.notes 
Request: Send a blank email to php-notes+get-105183@lists.php.net to get a copy of this message
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. ---- Server IP: 80.241.173.254 Probable Submitter: 213.92.98.14 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.xml.php Edit -- http://master.php.net/note/edit/62817 Del: integrated -- http://master.php.net/note/delete/62817/integrated Del: useless -- http://master.php.net/note/delete/62817/useless Del: bad code -- http://master.php.net/note/delete/62817/bad+code Del: spam -- http://master.php.net/note/delete/62817/spam Del: non-english -- http://master.php.net/note/delete/62817/non-english Del: in docs -- http://master.php.net/note/delete/62817/in+docs Del: other reasons-- http://master.php.net/note/delete/62817 Reject -- http://master.php.net/note/reject/62817 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105183) next »