webform1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace test15_3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml("<news>"
+ "<news_id>1</news_id>"
+ "<news_title>上海国际艺术节开幕</news_title>"
+ "<news_author>作者</news_author>"
+ "<news_ly>来源原创</news_ly>"
+ "<news_content>第十三届中国上海国际艺术节开幕。</news_content>"
+ "<news_adddate>2013-10-18 </news_adddate>"
+ "</news>");
doc.Save(Server.MapPath("XMLFile1.xml"));
Response.Write("文件写入成功!");
}
}
}