我看到有不同的方法可以创建 xml、添加节点并为它们设置属性。但我想了解这两者之间的区别:
XmlNode infoNode = xmlDocument.CreateNode(XmlNodeType.Element, "INFO", string.Empty);
XmlAttribute idAttribute = xmlDocument.CreateAttribute("Id");
idAttribute.Value = this._id.ToString();
infoNode.Attributes.Append(instanceIdAttribute);
XmlElement infoNode= setTCAreaXml.CreateElement("INFO");
infoNode.SetAttribute("Id", this._Id.ToString());
哪个最好用?谢谢!