I got this error:
Empty path name is not legal.
What is the problem with my code?
StringBuilder writer = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings() { OmitXmlDeclaration = true };
XmlWriter xmlWriter = XmlWriter.Create(strXML, settings);
xmlDoc.Save(xmlWriter);
strXML = writer.ToString();
It is not clear what you're trying to accomplish - the code sample provided doesn't actually compile.
However, this does and seems to have no issues:
XmlDocument xmlDoc = new XmlDocument();
XmlWriterSettings settings = new XmlWriterSettings() { OmitXmlDeclaration = true };
XmlWriter xmlWriter = XmlWriter.Create("xml.txt", settings);
xmlDoc.Save(xmlWriter);