note 60326 added to function.xml-set-character-data-handler

From: Date: Tue, 03 Jan 2006 21:41:23 +0000
Subject: note 60326 added to function.xml-set-character-data-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-101165@lists.php.net to get a copy of this message
re: jason at omegavortex dot com below, another way to deal with whitespace issues is: function charData($parser,$data) { $char_data = trim($data); if($char_data) $char_data = preg_replace('/ */',' ',$data); $this->cdata .= $char_data; } This means that: <p>here is my text <a href="something">my text</a> and here is some more after some spaces at the beginning of the line</p> comes out properly. You could do further replacements if you want to deal with tabs in your files. i only ever use spaces. if you only use trim() then you would lose the space before the <a> tag above, but trim() is a good way to check for completely empty char data, then just replace more than one space with a single space. this will preserve a single space at the beginning and end of the cdata. ---- 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+60326 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60326&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60326&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101165) next »