Preserve whitespaces in XML files

  • Thread starter Thread starter Martin Horst
  • Start date Start date
M

Martin Horst

Hi,

I'm using the XmlTextWriter class creating an XML document. In my case
it is necessary that values which are containing only whitespaces are
excatly written into an XML tag. I know that there is the XML attribute
xml:space="preserve". So I tried to add this attribute but nothing
happens. Also I inherited the XmlTextWriter class and overrided the
XmlSpace property. But this didn't work neither. So my question is: Can
I use the XmlTextWriter class for writing whitespaces?

Thanks in advance
Martin
 
I'm using the XmlTextWriter class creating an XML document. In my case
it is necessary that values which are containing only whitespaces are
excatly written into an XML tag. I know that there is the XML attribute
xml:space="preserve". So I tried to add this attribute but nothing
happens. Also I inherited the XmlTextWriter class and overrided the
XmlSpace property. But this didn't work neither. So my question is: Can
I use the XmlTextWriter class for writing whitespaces?

Have you tried using XmlWriter.Create, specifying appropriate
XmlWriterSettings (e.g. NewLineHandling=NewLineHandling.None)?

If this doesn't help, could you post a short but complete program
which demonstrates the problem?
See http://pobox.com/~skeet/csharp/complete.html for more on what I
mean by that.

Jon
 
Hi,
Have you tried using XmlWriter.Create, specifying appropriate
XmlWriterSettings (e.g. NewLineHandling=NewLineHandling.None)?

If this doesn't help, could you post a short but complete program
which demonstrates the problem?
See http://pobox.com/~skeet/csharp/complete.html for more on what I
mean by that.

I figured it out. It was not the problem of the XmlWriter class. The XML
document was ok. My problem was that I watched it the XML viewer of the
VS debugger. In the moment I'm fighting against the XmlReader class.


Best regards.
 
Back
Top