System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
System.Xml.XmlDeclaration dec = xml.CreateXmlDeclaration("1.0", "UTF-8", null);
xml.AppendChild(dec);
System.Xml.XmlElement ele = xml.CreateElement("A");
xml.AppendChild(ele);
System.Xml.XmlElement ele2 = xml.CreateElement("B");
System.Xml.XmlAttribute xa = xml.CreateAttribute("C");
xa.Value = "D";
ele2.Attributes.Append(xa);
ele2.InnerXml= "E";
ele.AppendChild(ele2);
xml.Save(Server.MapPath("~/1.xml"));