Farseer

导航

LinQ To XML 新建文件并增加节点

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会报错说此操作将创建一个错误结构的文档,因为试图增加两个根节点。

posted on 2012-02-27 23:12  佛西亚  阅读(707)  评论(1编辑  收藏  举报