SunilRai86
SunilRai86

Reputation: 1020

xml element not indented properly

i have created a xml file using c# but the main problem is that it is not indented

i have used xmldocument.preserverwhitespace=true;

Upvotes: 0

Views: 347

Answers (2)

hoang
hoang

Reputation: 1917

If you are using an XmlTextWriter, you can set the Formatting property :

XmlTextWriter xmlWriter = new XmlTextWriter("c:\ouputfile.xml", System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;

Upvotes: 2

Cylon Cat
Cylon Cat

Reputation: 7201

Strongly suggest you switch over to the new XML document model, based on XDocument. You can use LINQ to XML on it, and it's much easier to create, alter, and search XML than it ever wasin the old XMLDocument model. The new XDocument model can cut your code size by over half.

Upvotes: 0

Related Questions