ExtractionCursor ClassC# API
Stores details of an extraction from a Response.
Inheritance Hierarchy

System Object
  Facilita.Native ExtractionCursor

Namespace: Facilita.Native
Assembly: clrNativeWrapper (in clrNativeWrapper.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public class ExtractionCursor : IDisposable
Remarks

The current position in the page is stored, so an ExtractionCursor object can be re-used to find successive matches in a Response.
Examples

The following example demonstrates extracting multiple tokens from an XML response.
<setup>
<token>477BF7E1EA0</token>
<token>68189CA718B</token>
<token>44D4C768874</token>
<token>AC59664BBEF</token>
</setup>

If it is necessary to extract the tokens from this response and store them in a List<string>, the following method could be written which makes use of the ExtractionCursor class.

public List<string> FindTokens(Response response)
{
    // Create a List to store the tokens
    List<string> tokens = new List<string>();

    // Use an ExtractionCursor to remember our current position within the Response
    ExtractionCursor cursor = new ExtractionCursor();

    // Loop until we can't find any more tokens      
    do
    {
        // Extract the next token 
        string token = response.Extract(cursor, "<token>", "</token>", ActionType.ACT_NONE);
        if (cursor.Succeeded)
        {
            WriteMessage(String.Format("Found token {0} at position {1}", token, cursor.Index));
            tokens.Add(token);
        }
    }
    while (cursor.Succeeded);
    return tokens;
}
See Also