【发布时间】:2014-07-02 04:48:57
【问题描述】:
最初使用 System.Xml.Linq dll 版本 3.5.0.0 我已删除空元素,如下所示
XDocument document = XDocument.Load(_fileName);
document.Descendants().Where(e => string.IsNullOrEmpty(e.Value)).Remove();
document.Save(_fileName, SaveOptions.DisableFormatting);
现在我的 System.Xml.Linq dll 版本是 4.0.0.0 但上面的代码不起作用,因为我看不到 Where 子句。
谁能帮助我如何重写代码删除 4.0.0.0 中的空元素
【问题讨论】:
-
你的代码文件中有
using System.Xml.Linq;和using System.Linq;吗?