note 55777 deleted from ref.dom by didou
| From: | didou@php.net | Date: | Mon, 13 Mar 2006 00:04:31 +0000 |
| Subject: | note 55777 deleted from ref.dom by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-105403@lists.php.net to get a copy of this message | ||
Note Submitter: keyvez at hotmail dot com
----
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.