XDocument myXDoc = new XDocument(new XElement("Results"));
myXDoc.Save(_fileName)
XDocument xDocument = XDocument.Load(fileName);
                xDocument.Root.Add(new XElement("Result",new XAttribute("ItemId",this.itemId),new XAttribute("ItemName",this.itemName)));
如果不用xDocument.Root而是直接用xDocument.Add会报错说此操作将创建一个错误结构的文档,因为试图增加两个根节点。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-01-22
  • 2021-11-14
  • 2022-03-06
猜你喜欢
  • 2021-10-27
  • 2021-11-01
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
相关资源
相似解决方案