62,268
社区成员
发帖
与我相关
我的任务
分享
DataSet ds = new DataSet();
ds.WriteXml(Server.MapPath("~/xml/your.xml"));
static void writeXMLbyXMLwriter(XmlWriter writer, string symbol, double price, double change, long volume)
{
writer.WriteStartDocument();
writer.WriteStartElement("artworkinfo");
writer.WriteStartElement("albuminfo");
writer.WriteElementString("artLocation", "images/album2.jpg");
writer.WriteElementString("artist", "The Doors");
writer.WriteElementString("albumName", "Greatest Hits");
writer.WriteElementString("artistLink", "http://www.zcool.com.cn");
writer.WriteElementString("albumLink", "http://www.zcool.com.cn");
writer.WriteEndElement();
writer.WriteStartElement("albuminfo");
writer.WriteElementString("artLocation", "images/album1.jpg");
writer.WriteElementString("artist", "The White Stripes");
writer.WriteElementString("albumName", "Elephant");
writer.WriteElementString("artistLink", "http://www.zcool.com.cn");
writer.WriteElementString("albumLink", "http://www.zcool.com.cn");
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
}
protected void Button3_Click(object sender, EventArgs e)
{
string filename = TextBox5.Text;
System.IO.FileStream myfilestream = new System.IO.FileStream(filename, System.IO.FileMode.Create);
XmlTextWriter myxmlwriter = new XmlTextWriter(myfilestream, System.Text.Encoding.Unicode);
myxmlwriter.Formatting = Formatting.Indented;
try
{
writeXMLbyXMLwriter(myxmlwriter, "asf", 740.1, 5.0, 456789);
myxmlwriter.Close();
Page.Response.Write("成功!");
}
catch
{
Page.Response.Write("失败!");
}
}