Replaces text in an XML file at the location specified by an XPath expression.
For a list of all members of this type, see XmlPokeTask Members.
System.Object
NAnt.Core.Element
NAnt.Core.Task
NAnt.Core.Tasks.XmlPokeTask
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
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.
Change the server
setting in the configuration from testhost.somecompany.com
to productionhost.somecompany.com
.
XML file:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="server" value="testhost.somecompany.com" /> </appSettings> </configuration>
Build fragment:
<xmlpoke file="App.config" xpath="/configuration/appSettings/add[@key = 'server']/@value" value="productionhost.somecompany.com" />
Modify the noNamespaceSchemaLocation
in an XML file.
XML file:
<?xml version="1.0" encoding="utf-8" ?> <Commands xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Path Value"> </Commands>
Build fragment:
<xmlpoke file="test.xml" xpath="/Commands/@xsi:noNamespaceSchemaLocation" value="d:\Commands.xsd"> <namespaces> <namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" /> </namespaces> </xmlpoke>
Namespace: NAnt.Core.Tasks
Assembly: NAnt.Core (in NAnt.Core.dll)
XmlPokeTask Members | NAnt.Core.Tasks Namespace