如何根据内部值比较删除 XML 节点
我有一个具有以下结构的 XML 文件:
<tu>
<tuv xml:lang="EN">
<seg>XXX</seg>
</tuv>
<tuv xml:lang="FR">
<seg>YYY</seg>
</tuv>
</tu>
<tu>
<tuv xml:lang="EN">
<seg>XXX</seg>
</tuv>
<tuv xml:lang="FR">
<seg>YYY</seg>
</tuv>
</tu>
...
当
等于 <时,我想删除节点
来自 C# 应用程序的 code>
预先非常感谢!
I have an XML file with the following structure:
<tu>
<tuv xml:lang="EN">
<seg>XXX</seg>
</tuv>
<tuv xml:lang="FR">
<seg>YYY</seg>
</tuv>
</tu>
<tu>
<tuv xml:lang="EN">
<seg>XXX</seg>
</tuv>
<tuv xml:lang="FR">
<seg>YYY</seg>
</tuv>
</tu>
...
And I would like to delete the node <tu>
when <seg>XXX</seg>
is equal to <seg>YYY</seg>
from a C# application. I have tried with linq and in some other ways, but I wasn't able to compare those internal valuea and then delete the parent node if necessary.
Thanks a lot in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您的 XML 无效,因此我添加了一个
节点 - 然后这对我有用:First of all your XML is invalid so I added a
<root>
node - then this worked for me: