NAnt
![]() ![]() ![]() |
v0.85 |
[This is preliminary documentation and subject to change.]
Replaces text in an XML file at the location specified by an XPath expression.
The location specified by the XPath expression must exist, it will not create the parent elements for you. However, provided you have a root element you could use a series of the tasks to build the XML file up if necessary.
Attribute | Type | Description | Required |
---|---|---|---|
file | file | The name of the file that contains the XML document that is going to be poked. | True |
value | string | The value that replaces the contents of the selected nodes. | True |
xpath | string | The XPath expression used to select which nodes are to be modified. | True |
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False |
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False |
unless | bool | Opposite of if . If false then the task will be executed; otherwise, skipped. The default is false. |
False |
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False |
Contains a collection of XmlNamespace elements.
The example provided assumes that the following XML file (App.config) exists in the current build directory.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="server" value="testhost.somecompany.com" /> </appSettings> </configuration>
The example will change the server
setting in the above configuration from testhost.somecompany.com
to productionhost.somecompany.com
.
<xmlpoke file="App.config" xpath="/configuration/appSettings/add[@key = 'server']/@value" value="productionhost.somecompany.com" />