Maybe this will do the trick:
- petterCode:// Load document. XmlDocument pDoc = new XmlDocument(); pDoc.Load("input.xml"); // Get first node (and check if it is a xml declaration). XmlDeclaration pDecl = pDoc.FirstChild as XmlDeclaration; if (pDecl == null) { // No xml declaration exists, create one. pDecl = pDoc.CreateXmlDeclaration("1.0", null, null); pDoc.InsertBefore(pDecl, pDoc.FirstChild); } else { // Modify the one we got. pDecl.Encoding = null; } // Save document. pDoc.Save("output.xml");




Reply With Quote