开发者

XLinq: Remove certain XElements from a xml file which are saved in a LIst<XElement>

I can not remove nodes while I iterate them thats ok.´

I have a List with Guid`s in it.

I want to delete all XElements in that xml file where the XElement has a Guid of that List

thats my xml file:

<?xml version="1.0" encoding="utf-8"?>
<Departments>
  <Department Id="2d55ba71-a2ab-44a1-a697-f57bbd238c7f" />
  <Department Id="775cd4c2-74c9-开发者_Python百科4f41-9ddf-1126c508cccb" />
</Departments>

That does not work: xDoc.Descendants("Department ").Remove<XElement>().Where...

How can I make that work?


I'm just guessing quickly but try this:

xDoc.Descendants("Department").Where(/* match code */).Remove();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜