views:

34

answers:

2

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

i have used xmldocument.preserverwhitespace=true;

A: 

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.

Cylon Cat
If you're going to downvote, please provide a reason, if for no other reason than to inform the original poster of the reason for disagreement. (Not to mention that silent downvoting is very rude.)
Cylon Cat
+2  A: 

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;
hoang