110,995
社区成员
发帖
与我相关
我的任务
分享
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = (" ");
using (XmlWriter writer = XmlWriter.Create(Server.MapPath(".") + @"\img.xml", settings))
{
// Write XML data.
//writer.WriteStartElement("book");
//writer.WriteElementString("price", "19.95");
writer.WriteStartElement("img");
writer.WriteAttributeString("src", "aa.jpg");
writer.WriteEndElement();
writer.Flush();
}
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = (" ");
using (XmlWriter writer = XmlWriter.Create("books.xml", settings)) {
// Write XML data.
writer.WriteStartElement("book");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
writer.Flush();
}