引用:System.Xml;
XmlDocument doc = new XmlDocument(); XmlElement Root = doc.CreateElement("Root");//主内容 doc.AppendChild(Root); XmlElement Child1 = doc.CreateElement("attr1"); XmlAttribute attr1= doc.CreateAttribute("attr1"); attr1.Value = "arrt1Content"; Child1.Attributes.Append(attr1); Root.AppendChild(Child1); //这一行和上面顺序不能反 //arr1就你的字段,如字段中有引号就要用\' ,最好不要用xml 的text段存内容 //如果你有170 你的循环要对 应该有两个循环 一个在attr1 这 用于添加150个字段 一个在child1 用于添加几行 // doc.InnerXml 这个属性就是你的xml 内容 doc.Save("c://1.xml");//保存这个xml 网页或exe 都可以