WebParseHtmlBoundEx function

Action

Parses the HTML content for sLeftBoundary and sRightBoundary and stores the string between these boundaries in sResult. If the right delimiter (sRightBoundary) is not specified (set to NULL), the string after sLeftBoundary with length nMaxResultLen is returned. If the left delimiter (sLeftBoundary) is not specified (set to NULL), the string from beginning to the right delimiter with a maximum length of nMaxResultLen is returned. If both boundary search strings are omitted (sLeftBoundary and sRightBoundary are set to NULL), all data with maximum length is stored into sResult. If the nMaxResultLen is set to STRING_COMPLETE an unlimited amount of data is stored in the sResult parameter.

When verifying/parsing an HTML page that consists of multiple frames, you can specify which frame document to verify/parse by specifying the sFrame parameter. By default, all HTML documents of the HTML page are scanned. This applies to HTML pages that are retrieved through a page-level command like WebPageUrl or WebPageLink.

It is important to know that all parsing and verification functions must be specified before the Web API call for which the response data should be parsed/verified. You can specify multiple parse/verification functions before a Web API call. The order of the parse/verification functions is not relevant (Exception: WebParseDataBound and WebVerifyDataBound using the flag WEB_FLAG_SYNCHRON).

Include file

WebAPI.bdh

Syntax

WebParseHtmlBoundEx(out sResult         : string,
                    in  nMaxResultLen   : number optional,
                    in  sLeftBoundary   : string optional,
                    in  nLeftOccurrence : number optional,
                    in  sRightBoundary  : string optional,
                    in  nOptions        : number optional,
                    in  sFrame          : string optional,
                    out nBytesParsed    : number optional);

Return value

  • none

Parameter Description

sResult

String variable that receives the string between the specified boundary strings.

nMaxResultLen Maximum length of the string to return (optional). If this parameter is omitted or set to STRING_COMPLETE all available data is stored in sResult.
sLeftBoundary Left boundary of the HTML content to compare.
nLeftOccurrence The sLeftBoundary has to be found nLeftOccurrence times, before the copy process starts and the right boundary is searched (optional). The default value is one. Provide WEB_OCCURENCE_LAST to specify the last Occurrence.
sRightBoundary Right boundary of the HTML content to compare.

nOptions

Parsing options (optional). If this flag is omitted, none of the listed options are applied, meaning that the string comparison is case-insensitive, white spaces are not ignored, etc.

WEB_FLAG_CASE_SENSITIVE
If this flag is set the string compare operation is case sensitive.
WEB_FLAG_IGNORE_WHITE_SPACE
If this flag is set all white spaces are ignored.
WEB_FLAG_DONT_FORCE_LOAD
Specify this option to enable caching for the subsequent request. Note that nothing is parsed if the specified table is not loaded (cache hit).
WEB_FLAG_RULE
Specify this flag to perform the parsing operation in every subsequent Web function. After every Web function the specified output variables are set to the new value. If you want to use the variables in other transactions or in event handler functions, you must use global variables. Call WebCancelAllRules() to disable all verification and parsing rules.
Important: The option WEB_FLAG_RULE should only be used in the INIT transaction or in combination with the WebCancelAllRules function.
sFrame Frame that gets searched for the content string (optional). If this parameter is omitted the whole page is scanned.
nBytesParsed Variable receiving the number of the bytes that are actually parsed (optional).

Example

dcltrans
  transaction TMain
  var
    nResult : number;
    sResult : string;
  begin
    WebParseHtmlBoundEx(sResult, STRING_COMPLETE, "Begin", 2, "X.X");
    WebPageUrl("http://mycompany.com/");
    Print(sResult);
    
    WebParseHtmlBoundEx(sResult, STRING_COMPLETE, "Begin", 2, "X.X", WEB_FLAG_IGNORE_WHITE_SPACE, "FrameA", nResult);
    WebUrl("http://mycompany.com/Shop/default.htm");
    Print(sResult);
    Print(string(nResult) + "Bytes parsed");
  end TMain;