Response ExtractXPath Method C# API
Returns a string object from the HTML or XML response content that matches the given XPath expression.

Namespace: Facilita.Web
Assembly: clrWebBrowser (in clrWebBrowser.dll) Version: 9.5.7.98 (1.0.0.0)
Syntax

public virtual string ExtractXPath(
	string xpathExpression,
	ActionType failAction
)

Parameters

xpathExpression
Type: System String
The XPath expression to be applied to the response content.
failAction
Type: Facilita.Fc.Runtime ActionType
The action to take if the extract failed.

Return Value

The extracted text, or an empty string if the extract failed.
Remarks

This method is only applicable if the response content is either HTML or XML. The method returns the first element or attribute value that matches the XPath expression.
Examples

The following example demonstrates extracting a value from an HTML Response using an XPath expression. The value returned is stored in the required extract variable.
Response response = request.Send();
Set<string>("xpathExtractVariable", response.ExtractXPath("/html/body/h1", ActionType.ACT_WARNING));

// Check if a value was extracted. 
if (GetString("xpathExtractVariable").Length > 0)
{
    WriteMessage(String.Format("xpathExtractVariable: {0}", GetString("xpathExtractVariable")));
}
else
{
    WriteMessage("XPath extract found no match");
}
See Also