森林海
using System;using System.Xml;namespace ConsoleApplication3{class Program{static void Main(string[] args){XmlDocument doc = new XmlDocument(); // 创建dom对象XmlElement root = doc.CreateElement("album"); // 创建根节点albumroot.SetAttribute("name", "album1"); // 设置属性doc.AppendChild(root); // 加入到xml documentXmlElement preview = doc.CreateElement("Preview"); // 创建preview元素preview.SetAttribute("path", "album1"); //preview.SetAttribute("extension", "xpi"); //preview.SetAttribute("sizew", "680"); // 设置属性preview.SetAttribute("sizeh", "474"); //preview.SetAttribute("totalpage", "25"); //root.AppendChild(preview); // 添加到xml document//下面一样,不一行行写解释了XmlElement page = doc.CreateElement("Page");page.SetAttribute("id", "0");page.SetAttribute("text", "封面");page.SetAttribute("bgimg", "fm.xpi");page.SetAttribute("sizew", "680");page.SetAttribute("sizeh", "474");page.SetAttribute("totalphoto", "2");preview.AppendChild(page);XmlElement photo1 = doc.CreateElement("Photo");photo1.SetAttribute("id", "0");photo1.SetAttribute("x", "0");photo1.SetAttribute("y", "0");photo1.SetAttribute("minw", "5029");photo1.SetAttribute("minh", "3504");photo1.SetAttribute("pwidth", "680");photo1.SetAttribute("pheight", "474");photo1.SetAttribute("image", "hard_cover_color.xpi");page.AppendChild(photo1);XmlElement photo2 = doc.CreateElement("Photo");photo2.SetAttribute("id", "1");photo2.SetAttribute("x", "138");photo2.SetAttribute("y", "117");photo2.SetAttribute("minw", "3155");photo2.SetAttribute("minh", "1925");photo2.SetAttribute("pwidth", "406");photo2.SetAttribute("pheight", "243");photo2.SetAttribute("image", "sampleS.xpi");page.AppendChild(photo2);doc.Save(@"album\album1.xml"); // 保存文件}}}