using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Text; using System.Xml; using System.Xml.Linq; namespace WMS.Common { public class XMLHelper { #region 构造函数 /// /// 构造函数 /// public XMLHelper() { } #endregion private XDeclaration Declaration = new XDeclaration("1.0", "uft-8", "no"); #region 创建XML /// /// 根据XElement创建XML文件 /// /// /// public static void CreateXML(XElement el, string filename) { XDocument doc = new XDocument(el); doc.Save(filename); } /// /// 根据XML文本文件内容创建XML /// /// /// public void CreateXML(string xml, string filename) { XElement el = XElement.Parse(xml); XDocument doc = new XDocument(Declaration, el); doc.Save(filename, SaveOptions.None); } /// /// 将DataTable转化成XML文件,并保存 /// /// /// public void CreateXML(DataTable table, string fileName) { //设置默认xml文件名 if (string.IsNullOrEmpty(fileName)) { fileName = @"XMLData\" + table.TableName; } DataSet ds = new DataSet(); ds.Tables.Add(table); ds.WriteXml(fileName); } #endregion #region 查询XML文件 public void SelectXML(string fileName, string Node) { } #endregion #region UpdateXML #endregion #region AddXml #endregion } }