System.Xml - Controlling linebreak/indentation on child/inline ele

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm going insane fighting against the xml reader/writer. I have xml that
should look like this:

<source><g>varname</g> some text <g>varname</g> <g>varname></source>

This is a simplified version, but the point is that all spaces in the
<source> element are significant. My problem is two-fold. First, the writer
is determined to format this like so:

<source>
<g>varname</g> some text <g>varname</g> <g>varname></source>

If I use the xml:space="preserve" attribute, I get the linebreak and
indentation spaces. If I don't, I lose the space between </g> and <g>. The
problem comes in when there might actually be significant spaces before the
first <g> element. Distinguishing between significant spaces and the
indentation spaces can't seem to be done. So the solution is probably to have
the writer not put the <g> elements on a seperate line. But I can't figure
out how to do this. Or maybe there's another way?

This is killing me. Please help.
 
Have you tried setting the Xmldocument's preserveWhitespace=true and the
xmlwrite.Formmating=Formatting.None?
 
Back
Top