XmlPeekAliases.

XmlPeek(ICakeContext, FilePath, string, XmlPeekSettings) Method

Summary

Get the value of a target node.
Namespace
Cake.Common.Xml
Containing Type
XmlPeekAliases

Syntax

[CakeMethodAlias]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
public static string XmlPeek(this ICakeContext context, FilePath filePath, string xpath, XmlPeekSettings settings)

Examples

XML document:
<?xml version="1.0" encoding="UTF-8"?>
<pastery xmlns = "https://cakebuild.net/pastery" >
    <cake price="1.62" />
</pastery>

XmlPeek usage:

string version = XmlPeek("./pastry.xml", "/pastry:pastry/pastry:cake/@price",
    new XmlPeekSettings {
        Namespaces = new Dictionary<string, string> {{ "pastry", "https://cakebuild.net/pastry" }}
    });
string unknown = XmlPeek("./pastry.xml", "/pastry:pastry/pastry:cake/@recipe",
    new XmlPeekSettings {
        Namespaces = new Dictionary<string, string> {{ "pastry", "https://cakebuild.net/pastry" }},
        SuppressWarning = true
    });

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.
SuppressMessageAttribute

Parameters

Name Type Description
context ICakeContext The context.
filePath FilePath The target file.
xpath string The xpath of the nodes to set.
settings XmlPeekSettings Additional settings to tweak Xml Peek behavior.

Return Value

Type Description
string The value found at the given XPath query.