创建xml文件
XmlDocument doc = new XmlDocument();
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.AppendChild(decl);
XmlElement ele = doc.CreateElement("bookstory");
ele.InnerText = "新华书店";
ele.SetAttribute("book", "10");
doc.AppendChild(ele);
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter writer = XmlWriter.Create(@"D:\book.xml", settings);
doc.WriteTo(writer);
writer.Close();