XmlDocument doc = new XmlDocument();
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.AppendChild(dec);
//根节点
XmlNode rootNode = doc.CreateElement("Team");
//节点属性
XmlAttribute nameAttr= doc.CreateAttribute("Name");
nameAttr.Value = "abc";
rootNode.Attributes.Append(nameAttr);
doc.AppendChild(rootNode);
//增加样地属性
for (int i = 0; i < 10; i++)
{
XmlNode ydNode = doc.CreateElement("YD");
XmlAttribute ydAttr = doc.CreateAttribute("YDH");
ydAttr.Value = "1000";
ydNode.Attributes.Append(ydAttr);
rootNode.AppendChild(ydNode);
}
doc.Save("c:\\abc.xml");
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.AppendChild(dec);
//根节点
XmlNode rootNode = doc.CreateElement("Team");
//节点属性
XmlAttribute nameAttr= doc.CreateAttribute("Name");
nameAttr.Value = "abc";
rootNode.Attributes.Append(nameAttr);
doc.AppendChild(rootNode);
//增加样地属性
for (int i = 0; i < 10; i++)
{
XmlNode ydNode = doc.CreateElement("YD");
XmlAttribute ydAttr = doc.CreateAttribute("YDH");
ydAttr.Value = "1000";
ydNode.Attributes.Append(ydAttr);
rootNode.AppendChild(ydNode);
}
doc.Save("c:\\abc.xml");