Problems with intending XML on C#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hey, Guys!
Ive reached a problem with intending XmlDocument.
Heres my beautifying function:
public string Beautify(XmlDocument doc)
{<br/>
StringBuilder sb = new StringBuilder();<br/>
XmlWriterSettings settings = new XmlWriterSettings();<br/>
settings.Indent = true;<br/>
settings.IndentChars = "t";<br/>
settings.NewLineChars = "rn";<br/>
settings.NewLineHandling = NewLineHandling.Replace;<br/>
using (XmlWriter writer = XmlWriter.Create(sb, settings)) doc.Save(writer);<br/>
return sb.ToString();<br/>
}
after operating, it intends only first tag (<?xml version="1.0"?>)
All the other tags stay in one line.
Whats wrong?

View the full article
 
Back
Top