C# 如何在xml中搜索节点并删除其子元素?
我有以下格式的xml:C# 如何在xml中搜索节点并删除其子元素?,c#,xml,C#,Xml,我有以下格式的xml: <svg xmlns:xlink="http://www.w3.org/1999/xlink" style="font-family: 'lucida grande', 'lucida sans unicode', arial, helvetica, sans-serif;font-size: 12px" xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="400">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" style="font-family: 'lucida grande', 'lucida sans unicode', arial, helvetica, sans-serif;font-size: 12px" xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="400">
<g class="highcharts-axis-labels highcharts-xaxis-labels">
<text style="position: absolute; color: #606060; font-size: 11px; cursor: default; fill: #606060" opacity="1" z="32" x="107" y="300" transform="translate(0,0) rotate(45 107 300)" text-anchor="start">
<tspan>% Service FTE</tspan>
<tspan x="107" dy="15">Offshore/Total</tspan>
<tspan x="107" dy="15">Service FTE</tspan>
</text>
<text style="position: absolute; color: #606060; font-size: 11px; cursor: default; fill: #606060" opacity="1" z="32" x="493" y="300" transform="translate(0,0) rotate(45 493 300)" text-anchor="start">
<tspan>Setup costs as %</tspan>
<tspan x="493" dy="15">of sales EAR</tspan>
</text>
</g>
<g class="highcharts-axis-labels highcharts-yaxis-labels">
<text style="position: absolute; color: #606060; font-size: 11px; cursor: default; fill: #606060" opacity="1" z="29" x="64" y="289" text-anchor="end">0</text>
<text style="position: absolute; color: #606060; font-size: 11px; cursor: default; fill: #606060" opacity="1" z="15" x="62" y="238" text-anchor="end">25</text>
</g>
<g style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; white-space: nowrap; cursor: default; padding-top: 0px" class="highcharts-tooltip" transform="translate(0,-9999)">
<path d="M 3 0 L 13 0 C 16 0 16 0 16 3 L 16 13 C 16 16 16 16 13 16 L 3 16 C 0 16 0 16 0 13 L 0 3 C 0 0 0 0 3 0" fill="none" stroke="black" stroke-width="5" transform="translate(1, 1)" stroke-opacity="0.05"></path>
<path d="M 3 0 L 13 0 C 16 0 16 0 16 3 L 16 13 C 16 16 16 16 13 16 L 3 16 C 0 16 0 16 0 13 L 0 3 C 0 0 0 0 3 0" fill="rgba(249, 249, 249, .85)" stroke-width="1"></path>
<text style="position: absolute; color: #333333; font-size: 12px; fill: #333333" x="8" y="21"></text>
</g>
<text style="position: absolute; color: #909090; font-size: 9px; cursor: pointer; fill: #909090" x="590" y="395" text-anchor="end"></text>
</svg>
%服务全职员工
离岸/总计
服务全职员工
安装成本为%
销售耳
0
25
我想更新某些节点,如
tspan x=“493”dy=“15”
etc并删除最后一个节点和最后一个节点及其子节点(如果有)
请提供帮助。通过每个节点循环完成了任务。感谢大家向我们展示您的代码并询问您在哪里面临问题特别是,我建议使用LINQ to XML作为一个非常好的XML API。这应该很容易实现你的目标-尝试一下,用你尝试过的和出错的地方编辑你的问题。谢谢你,这很有帮助。。。