15

我在 web.config 中有以下节点:

<configuration>
...
<scheduling>
 <agent>
  <param desc="database">core</param>
 </agent>
 <agent>
  <param desc="database">master</param>
 </agent>
</scheduling>
...
</configuration>

我想删除<agent>带有主内容的子参数节点的整个节点。我的 xdt 变换节点或多或少看起来像:

<configuration>
...
<scheduling>
  <agent
         xdt:Transform="Remove"
         xdt:Locator="XPath(./param[@desc='database']/??????)" />
</scheduling>
...
</configuration>

如您所见,我不知道如何与节点内容字符串匹配。我需要在这里添加什么?

环境注意事项:windows 7 - visual studio 2010 SP1

4

1 回答 1

14

text()在定位器中添加一个额外的测试。匹配<param>节点:

xdt:Locator="XPath(./param[@desc='database' and text()='master'])">

编辑:要匹配<agent>您需要移动param到 XPath 匹配的谓词的节点:

xdt:Locator="Condition(param/@desc='database' and param/text()='master')">
于 2012-03-14T17:51:09.743 回答