public virtual void Save(string filename)
{
if (DocumentElement == null)
throw new XmlException(SR.Xml_InvalidXmlDocument, SR.Xdom_NoRootEle);
XmlDOMTextWriter xw = new XmlDOMTextWriter(filename, TextEncoding);
try
{
if (_preserveWhitespace == false)
xw.Formatting = Formatting.Indented;
WriteTo(xw);
xw.Flush();
}
finally
{
xw.Close();
}
}