Response Extract Method (ExtractionCursor, List String , String, String, Boolean)C# API
Extracts text from the response content - everything between (but not including) the specified list of before and after string objects - returning the defaultValue if they cannot be found, and specifying whether the search will be case-sensitive.

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

public string Extract(
	ExtractionCursor cursor,
	List<string> before,
	string after,
	string defaultValue,
	bool caseSensitive
)

Parameters

cursor
Type: Facilita.Native ExtractionCursor
An ExtractionCursor object to store the success/failure of the action, and the index in the response at which the match was found.
before
Type: System.Collections.Generic List String 
Each string in this List is searched for sequentially in the response content, and the returned string starts immediately after all the string objects have been matched in the content.
after
Type: System String
This text is searched for in the response content after the before text has been found, and the returned string ends immediately before this text occurs in the content.
defaultValue
Type: System String
The value to return if either the before or after text cannot be found.
caseSensitive
Type: System Boolean
true if the search should be case-sensitive.

Return Value

The extracted text, or defaultValue if the extract failed.
Remarks

Information about the success/failure of this method will be stored in the ExtractionCursor object passed.

Supplying a List<string> of before values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned until after is matched. See the example below, in which a known unique name (f_custid) is used to narrow the search.

Examples

The following example demonstrates using a list of strings to narrow down the search for text to extract from a HTML Response.
Response response = request.Send();
ExtractionCursor cursor = new ExtractionCursor();

// extract the f_custid value from the HTML text, defaulting to "00000" if the value cannot be found 
// <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> 
// <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> 
// <input type="text" name="f_account" size="10" maxlength="10" value="9876543">

List<string> before = new List<string>();
before.Add("f_custid");
before.Add("value=\"");

string extractedText = response.Extract(
                        cursor,
                        before,
                        "\"",
                        "00000",
                        true);

if (cursor.Succeeded)
{
    WriteMessage(string.Format("The value {0} was found at position {1}", extractedText, cursor.Index));
}
See Also