1、根据xml格式的string生成xml文件并保存到本地
1 /// <summary> 2 /// 保存XML到磁盘 3 /// </summary> 4 /// <param name="xml">xml格式的string</param> 5 public void SaveDocXml(string xml, int objectID) 6 { 7 string path = ""; 8 string xmlName = ""; 9 try 10 { 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 try 16 { 17 xmlDoc.LoadXml(xml); 18 } 19 catch (System.Exception ex) 20 { 21 logger.WriteExceptionLog(ex, "LoadXml Exception xml=" + xml); 22 } 23 try 24 { 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 }