Search code examples
xdt-transform

xdt:transform with similar attributes


I have a configuration file that contains WCF settings:

<host>
    <add baseAddress="net.tcp://myaddress.com:12345/MyService"/>
    <add baseAddress="net.tcp://anotheraddress:67890/MyOtherService"/>
</host>

The 'add' element only has a baseAddress attribute and so I can't use the Match locator. How would one approach transforming multiple elements like in my example?


Solution

  • What I ended up doing was moving the xdt:Transform="Replace" to the parent node like:

    <host xdt:Transform="Replace">
        <add baseAddress="net.tcp://myaddress.com:12345/MyService"/>
        <add baseAddress="net.tcp://anotheraddress:67890/MyOtherService"/>
    </host>