Xml – Add attribute to an xml node with nant


Is there a way to add an attribute to an xml node (which I have the xpath of) using nant?
Tried xmlpoke but it looks like it can only update existing attributes.


Best Solution

XmlPoke will definitely not work because the xpath must match something in the first place to be able to replace it.

The only way I know of doing this is to create your own task that would allow you to add data to an xml file. These new tasks can either be build separately and added to NAnt by copying dlls into NAnt\bin folder, or by extending NAnt directly from your build files

The information to get you started is found on <script/> Task

If you happen to make this task generic enough, it might be good to try to submit it to NAntContrib so everyone benefits.