Nant xmlpoke whole blocks

It took me awhile today to use the nant/xmlpoke/xpath to update our copyright message in our application so I’ll document it here.

The xmlpoke documentation explains whole to replace parameters but not children nodes. The simple answer is just define the parent in the xpath.

Thus to update/repalce the copyright string to have the correct current year, in a  resource file (strings.resx) which looks like:

<?xml version="1.0" encoding="utf-8"?>
  <!-- other stuff -->
  <data name="About_Copyright" xml:space="preserve">
    <value>Copyright © 2008-2009 Company Name.</value>
  <!-- more stuff -->

You would want use this xmlpoke/xpath

xpath="/root/data[@name = 'About_Copyright']/value"
value="Copyright © 2008-${datetime::get-year(datetime::now())} Company Name." />

Simple really (the xpath), but until I got it, it wasn’t.