NAnt SDK Documentation - v0.92

XmlPeekTask Class

Extracts text from an XML file at the location specified by an XPath expression.

For a list of all members of this type, see XmlPeekTask Members.

System.Object
   NAnt.Core.Element
      NAnt.Core.Task
         NAnt.Core.Tasks.XmlPeekTask

[Visual Basic]
<TaskName(Name:="xmlpeek")>
Public Class XmlPeekTask
    Inherits Task
[C#]
[TaskName(Name="xmlpeek")]
public class XmlPeekTask : Task

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

If the XPath expression specifies multiple nodes the node index is used to determine which of the nodes' text is returned.

Example

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 xmlns="http://www.gordic.cz/shared/project-config/v_1.0.0.0">
    <appSettings>
        <add key="server" value="testhost.somecompany.com" />
    </appSettings>
</configuration>
    
  

The example will read the server value from the above configuration file.

    
<xmlpeek
    file="App.config"
    xpath="/x:configuration/x:appSettings/x:add[@key = 'server']/@value"
    property="configuration.server">
    <namespaces>
        <namespace prefix="x" uri="http://www.gordic.cz/shared/project-config/v_1.0.0.0" />
    </namespaces>
</xmlpeek>
    
  

Requirements

Namespace: NAnt.Core.Tasks

Assembly: NAnt.Core (in NAnt.Core.dll)

See Also

XmlPeekTask Members | NAnt.Core.Tasks Namespace