日期:2014-05-17 浏览次数:20498 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
private string file;
protected void Page_Load(object sender, EventArgs e)
{
file = Path.Combine(Request.PhysicalPath, @"App_Data\SuperProductiList.xml");
}
protected void Button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream(file, FileMode.Create);
XmlTextWriter w = new XmlTextWriter(fs, null);
w.WriteStartDocument();
w.WriteStartElement("Super");
w.WriteComment("This file generated by the XmlTextWriter class.");
w.WriteStartElement("Product");
w.WriteAttributeString("ID", "1");
w.WriteAttributeString("Name", "Chair");
w.WriteStartElement("price");
w.WriteString("49.5");
w.WriteEndElement();
w.WriteEndElement();
w.WriteEndElement();
w.WriteEndDocument();
w.Close();
}
}