using(XmlTextWriter writer = new XmlTextWriter(Server.MapPath(ResolveUrl("~/App_Data/test.xml")), System.Text.Encoding.UTF8)){
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
writer.WriteStartDocument(false);
writer.WriteStartElement("root");
writer.WriteStartElement("item");
writer.WriteAttributeString("id", "id_value");
writer.WriteAttributeString("description", "description_value");
writer.WriteAttributeString("parent", "parent_value");
writer.WriteValue("value");
writer.WriteEndElement();
writer.WriteEndElement();
}
參考網址
http://msdn.microsoft.com/zh-tw/library/z2w98a50(VS.80).aspx
留言列表