note 55777 added to ref.dom

From: Date: Fri, 12 Aug 2005 19:22:59 +0000
Subject: note 55777 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-93523@lists.php.net to get a copy of this message
More on the Famous White Space Problem I was driven to the point of insanity while parsing two XML files. One would parse just fine and the other would give errors. The preserveWhiteSpace property when set to false would remove white space from one file but not from the other. So I knew that there was problem with the XML file and not with the parser problem. The XML was well formed so it was not the XML, it had to be something that I couldn't see. It was the white space. Windows stores a newline as a string of two characters i.e. \r\n and unix stores them as just \n. The preserveWhiteSpace function when set to false would remove all the \n from outside the tags but the \r character still remains if the file is encoded in the windows (wrong) newline format. So I use the following which adds to the complexity of the program but does the job. <?php $XMLFileContent = implode('',spliti("\r",implode('',file($Template)))); ?> Note: This could be improved if efficiency is required. ---- Manual Page -- http://www.php.net/manual/en/ref.dom.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55777 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55777&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55777&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55777&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55777&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55777&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55777&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55777&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93523) next »