1.写xml
using System.Xml;

public void wrietXml(DataSet ds, string path)

...{
XmlDocument xmlDoc;
XmlNode xmlNode;
XmlElement xmlElem;

//XmlElement是XmlNode,但XmlNode不能增加属性,所以一般有了XmlElement再有XmlNode

xmlDoc = new XmlDocument();
//声明
xmlNode = xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
xmlDoc.AppendChild(xmlNode);
//根元素
xmlElem = xmlDoc.CreateElement("", "TableInfo", "");
xmlDoc.AppendChild(xmlElem);
XmlNode root = xmlDoc.SelectSingleNode("TableInfo");
//root.AppendChild(xmlElem);

//结构:TableInfo/table/field
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)

...{
XmlElement xe1 = xmlDoc.CreateElement("field");
string tableName = ds.Tables[0].Rows[i]["表名"].ToString();
if (tableName != "")

...{//增加table节点
xmlElem = xmlDoc.CreateElement("table");
xmlElem.SetAttribute("name", tableName);
xmlElem.SetAttribute("descript", "");
root.AppendChild(xmlElem);
}

//增加field节点
string fieldName = ds.Tables[0].Rows[i]["字段名"].ToString();
xe1.SetAttribute("name", fieldName);
xe1.SetAttribute("descript", "");
xmlElem.AppendChild(xe1);
}

xmlDoc.Save(path);
}











































2.读xml
(1)利用dataset


















(2)使用xml命名空间



















































