xdt transform locator that matches subnode content

我怕爱的太早我们不能终老 提交于 2019-12-18 14:52:27

问题


i have the following node in web.config:

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

i want to remove the whole <agent> node with the child param node with master content. more or less my xdt transform node looks like:

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

as you see, i have no idea how to match with the node content string. What do i need to add in here?

environment notes: windows 7 - visual studio 2010 SP1


回答1:


Add an extra test for text() into the locator. To match the <param> node:

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

EDIT: To match the <agent> node you need to move param into the predicate that XPath is matching:

xdt:Locator="Condition(param/@desc='database' and param/text()='master')">


来源:https://stackoverflow.com/questions/9707108/xdt-transform-locator-that-matches-subnode-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!