Skip to content

Assert

Performs an error check by asserting that the specified XPath evaluates to a boolean true value. If the assertion fails, an error is thrown.

1
myXml.Assert(xpath: string, message: string, detail: string):void

Parameters

string xpath
    XPath expression to be evaluated as a boolean.

string message
    Error message to display if the assertion fails. If not specified, a default "Assertion Failed" message is used.

string detail
    Optional XPath expression to evaluate and append to the error message for more detailed context.

Remarks

This method is useful for validating data within the XML structure.

Checking if the

Name

of a

Customer

is 'X'. If it is not, the message "Invalid customer" will be displayed, along with the actual value of the

Name

node.

1
$Xml.Assert("//Customer/Name = 'X'", "Invalid customer", "//Customer/Name");