1、根据xml格式的string生成xml文件并保存到本地
1 ///2 /// 保存XML到磁盘 3 /// 4 /// xml格式的string 5 public void SaveDocXml(string xml, int objectID) 6 { 7 string path = ""; 8 string xmlName = ""; 9 try10 {11 XmlDocument xmlDoc = new XmlDocument();12 XmlDeclaration xmldecl = xmlDoc.CreateXmlDeclaration("1.0", "GBK", ""); 13 path = "E:\\Archives\\";14 xmlName = System.IO.Path.Combine(path, objectID.ToString() + ".xml");15 try16 {17 xmlDoc.LoadXml(xml);18 }19 catch (System.Exception ex)20 {21 logger.WriteExceptionLog(ex, "LoadXml Exception xml=" + xml);22 }23 try24 {25 xmlDoc.Save(xmlName);26 }27 catch (System.Exception ex)28 {29 logger.WriteExceptionLog(ex, "Save Exception xml=" + xmlDoc.ToString());30 } 31 }32 catch (System.Exception ex)33 {34 logger.WriteExceptionLog(ex, "SaveDocXml Exception: " + "xmlName=" + xmlName);35 }36 }