我有一个看起来像这样的 xml 文档.我有一个如下结构的 XML 文件.示例 XML 如下:
I have an xml document that looks like this.I have a XML file structured as below. Sample XML is as follows:
<Dr.Watson>
<Bugs>
<Bug Name="Bug.add --> AAAAAAAAAAAA">
<criteria>
<includeFilterSets>
<filterSet>
<filter>
<filterName>PRODUCT_NAME</filterName>
<operator>
<name>Equals</name>
</operator>
<value>Dr.Watson</value>
</filter>
</filterSet>
</includeFilterSets>
<grouping>
<groupBy>
<name>STATUS</name>
</groupBy>
</grouping>
<caseSensitive>false</caseSensitive>
<entityToSearch>
<name>BUG</name>
</entityToSearch>
</criteria>
</Bug>
</Bugs>
</Dr.Watson>
我想替换 XML 文件中的一些元素,如下所示:
I want to replace some of elements in the XML file like below:
<Dr.Watson>
<Bugs>
<Bug Name="Bug.add --> AAAAAAAAAAAA">
<criteria>
<includeFilterSets>
<filterSet>
<filter>
<filterName>PRODUCT_NAME</filterName>
<operator>
<name>Equals</name>
</operator>
<value>Dr.Watson</value>
</filter>
</filterSet>
</includeFilterSets>
<grouping>
<groupBy>
<name>STATE</name>
</groupBy>
</grouping>
<caseSensitive>false</caseSensitive>
<entityToSearch>
<name>BUG</name>
</entityToSearch>
</criteria>
</Bug>
</Bugs>
</Dr.Watson>
我想更改可用的 under,然后是 as State.请提出建议.
i would like to change the available under followed by as State. Please suggest.
var xdoc = XDocument.Load(path_to_xml);
var groupByName = xdoc.XPathSelectElement("//groupBy/name");
groupByName.Value = "STATE";
xdoc.Save(path_to_xml);
这篇关于替换 XML 中的一些元素 [提供 XML 示例]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!