System.Xml.Document : How to write special characters in an xml file ?

Sep 28 2005 10:25 AM
Hello, I have a little problem when saving my xml file. I use an instance of System.Xml.Document. I load an xml document file and edit this file with an application, then when I save it (doc.save("file.xml") ), I would like also the whitespaces being saved.

Example: 
<element>
  <subElement>            </subElement>
</element>


It saves correctly the whitespaces, but when I read it again, the whitespaces are trimmed! To prevent that, I would like to replace whitespaces by :  &#32; but on saving the xml writer encodes this sequence into :  &amp;#32;  and therefore it is not interpreted as a whitespace anymore... :(( Any help would be really appreciated, thanks in advance!

Answers (1)