匹配子节点内容的 xdt 变换定位器 [英] xdt transform locator that matches subnode content
问题描述
我在 web.config 中有以下节点:
<预><代码><配置>...<调度><代理><param desc="database">core</param><代理><param desc="database">master</param></调度>...</配置>我想删除整个
节点以及带有主内容的子参数节点.或多或少我的 xdt 变换节点看起来像:
如您所见,我不知道如何与节点内容字符串匹配.我需要在这里添加什么?
环境注意事项:Windows 7 - Visual Studio 2010 SP1
将 text()
的额外测试添加到定位器中.匹配 节点:
xdt:Locator="XPath(./param[@desc='database' and text()='master'])">
要匹配
节点,您需要将 param
移动到 XPath 匹配的谓词中:
xdt:Locator="Condition(param/@desc='database' and param/text()='master')">
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
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')">
这篇关于匹配子节点内容的 xdt 变换定位器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!