Create XML with LoadXml(string) i..
时间:2010-10-11 来源:yaoxin2010
using System;
using System.Xml;
public partial class create_xml_string : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string xmlString = "<?xml version='1.0' encoding='UTF-8'?>";
xmlString += "<products>";
xmlString += "<product id='p3'>";
xmlString += "<name>Alpha</name>";
xmlString += "<price>1200</price>";
xmlString += "<stock>19</stock>";
xmlString += "<country>Germany</country>";
xmlString += "</product>";
xmlString += "</products>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
doc.Save(Server.MapPath("products-string.xml"));
Response.Redirect("products-string.xml"); // load file in browser
}
}