C#操作XML
XmlDocument xml = new XmlDocument();
XmlDeclaration dec = xml.CreateXmlDeclaration("1.0", null, null);
xml.AppendChild(dec);
XmlComment com = xml.CreateComment("这是注释");
xml.AppendChild(com);
XmlElement root = xml.CreateElement("symbol");
root.InnerText = "root";
xml.AppendChild(root);
XmlElement symbol = xml.CreateElement("symbol");
symbol.InnerText = "InnerText";
symbol.SetAttribute("ATT", "Attribute");
symbol.SetAttribute("ATT2", "Attribute2");
xml.DocumentElement.AppendChild(symbol);
XmlTextWriter xw = new XmlTextWriter("d:\\test.xml", null);
xw.Formatting = Formatting.Indented;
xml.WriteContentTo(xw);
xw.Close();