指定XML格式为
<班级>
<学生 学号="0443111241" 姓名="张三">
<成绩 语文="88" 数学="99" 英语="100" />
</学生>
<学生 学号="0443111121" 姓名="李四">
<成绩 语文="92" 数学="90" 英语="96" />
</学生>
</班级>
public string xmlCreate()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<班级></班级>");
XmlNode newNode =doc.CreateNode("element","学生","");
XmlNode root = doc.DocumentElement;
root.AppendChild(newNode);
XmlAttribute newAttribute = doc.CreateAttribute("学号");
newAttribute.Value = "0443111241";
newNode.Attributes.Append(newAttribute);
newAttribute = doc.CreateAttribute("姓名");
newAttribute.Value = "张三";
newNode.Attributes.Append(newAttribute);
XmlNode newNode1 = doc.CreateNode("element", "成绩", "");
newNode.AppendChild(newNode1);
newAttribute = doc.CreateAttribute("语文");
newAttribute.Value = "88";
newNode1.Attributes.Append(newAttribute);
newAttribute = doc.CreateAttribute("数学");
newAttribute.Value = "99";
newNode1.Attributes.Append(newAttribute);
newAttribute = doc.CreateAttribute("英语");
newAttribute.Value = "100";
newNode1.Attributes.Append(newAttribute);
newNode = doc.CreateNode("element", "学生", "");
root.AppendChild(newNode);
newAttribute = doc.CreateAttribute("学号");
newAttribute.Value = "0443111121";
newNode.Attributes.Append(newAttribute);
newAttribute = doc.CreateAttribute("姓名");
newAttribute.Value = "李四";
newNode.Attributes.Append(newAttribute);
newNode1 = doc.CreateNode("element", "成绩", "");
newNode.AppendChild(newNode1);
newAttribute = doc.CreateAttribute("语文");
newAttribute.Value = "92";
newNode1.Attributes.Append(newAttribute);
newAttribute = doc.CreateAttribute("数学");
newAttribute.Value = "90";
newNode1.Attributes.Append(newAttribute);
newAttribute = doc.CreateAttribute("英语");
newAttribute.Value = "96";
newNode1.Attributes.Append(newAttribute);
return doc.OuterXml;
}