15

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

lurscher
  • 25,930
  • 29
  • 122
  • 185

1 Answers1

14

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')">
lurscher
  • 25,930
  • 29
  • 122
  • 185
bouteillebleu
  • 2,456
  • 23
  • 32
  • hmm strange, this is just removing the 'master' node, leaving the node – lurscher Mar 14 '12 at 18:00
  • I think you had `` in quotes in your original post and it's not showing up properly (try editing your post to see if you can get it to show up? You need to put backticks around it). I've edited my answer with how to match the `` node. – bouteillebleu Mar 14 '12 at 18:13
  • the last expression you added just gives me an error :'Error 165 '/configuration/scheduling/agent/.[param/@desc='database' and param/text()='master']' has an invalid token. – lurscher Mar 14 '12 at 18:20
  • 1
    ok i edited your answer replacing the XPath call with Condition and now it works! – lurscher Mar 14 '12 at 18:43