Here is what I ended up doing. Is this the best way to do this?
XmlDeclaration dec =
m_XMLDocument.CreateXmlDeclaration("1.0",string.Em pty, "yes");
m_XMLDocument.InsertBefore((XmlNode)dec, (XmlNode)
m_XMLDocument.DocumentElement);
XmlTextWriter writer = new XmlTextWriter(m_FileName,
Encoding.Default);
writer.WriteRaw(m_XMLDocument.OuterXml);
writer.Flush();
writer.Close();
"Dan" <da*@dontspamme.com> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
I'm trying to write an XmlDocument to disk using an XmlTextWriter.
Everything is fine except that I can't get the XML declaration to come
out. I'm using the code below. What am I doing wrong?
XmlTextWriter writer = new XmlTextWriter(m_FileName,
Encoding.Default);
writer.WriteStartDocument(true);
m_XMLDocument.WriteTo(writer);
writer.Flush();
writer.Close();