参考XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); XmlNode root = doc.DocumentElement; //Create a new node. XmlElement elem = doc.CreateElement("price"); elem.InnerText="19.95"; //Add the node to the document. root.AppendChild(elem); Console.WriteLine("Display the modified XML..."); doc.Save(Console.Out);
string sql = "insert into xxx(...) values(" + a + ", " + b + "...)"//执行sql语句。 ...//生成xml string xml = "<?xml verstion=\"1.0\"?><root><a>" + a + "</a><b>" + b + "</b></root>"; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(xml); doc.Save(Request.MapPath("test.xml"));
http://www.winu.cn/space-14160-do-blog-id-12799.html
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>"); XmlNode root = doc.DocumentElement; //Create a new node.
XmlElement elem = doc.CreateElement("price");
elem.InnerText="19.95"; //Add the node to the document.
root.AppendChild(elem); Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out);
...//生成xml
string xml = "<?xml verstion=\"1.0\"?><root><a>" + a + "</a><b>" + b + "</b></root>";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(xml);
doc.Save(Request.MapPath("test.xml"));
可以实现
自己试试