WebParseHtmlBound 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.

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).

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.

Include file

WebAPI.bdh

Syntax

WebParseHtmlBound( out sResult        : string,
                   in  nMaxResultLen  : number optional,
                   in  sLeftBoundary  : string 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.
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 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 use global variables! Call WebCancelAllRules() do disable all verification and parsing rules.
Note: 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
    WebParseHtmlBound(sResult, STRING_COMPLETE, "Begin", "X.X");
    WebPageUrl("http://mycompany.com/");
    Print(sResult);

    WebParseHtmlBound(sResult,
STRING_COMPLETE, "Begin", "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;