Here's how I saved an XPathDocument to an XML file:
// myItems[0] is from a generic List<XPathDocument> list
XPathDocument document = myItems[0];
// Feels like there should be an easier way to do this.
XPathNavigator documentNav = document.CreateNavigator();
XmlTextWriter writer = new XmlTextWriter(
Server.MapPath(temporaryFiles + "/" +
fileId + ".xml"), System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.Indentation = 3;
writer.WriteStartDocument();
writer.WriteNode(documentNav, true);
writer.WriteEndDocument();
writer.Close();
Now here's how I saved an XmlDocument to an XML file:
// myItems[0] is from a generic List<XmlDocument> list
XmlDocument document = myItems[0];
document.Save(
Server.MapPath(temporaryFiles + "/" + fileId + ".xml"));