Search code examples
web-configxdt-transform

How to xdt:locator match() a node's text?


I want to use the InsertIfMissing function with a locator of the node's text(). I tried the following:

<SessionItem xdt:Transform="InsertIfMissing" xdt:Locator="Match(text())">new_item</SessionItem>

But it looks like the xdt doesn't recognize the text() function.

How can I make it work?


Solution

  • Possible with xdt:Locator="Condition(boolean(XPATH EXPERSSION)".

    For example,

    <SessionItem xdt:Transform="InsertIfMissing" xdt:Locator="Condition(boolean(//SessionItem[text()=&quot;new_item&quot;]))">new_item</SessionItem>