My goal is to indent manually written XML document programmatically using C# code.
At the moment I'm indenting it using XmlWriter as specified here.
But I still have two problems:
- After indentation all line breaks disappear (I do want to preserve artificial line break inside the XML document).
- Xml elements which has both text node and sub-elements - are merged to one line. For example:
<element>text <subElement></subElement> </element>
will be indented to this:
<element>text<subElement></subElement></element>
I guess both of the above problems are actually the same problem.