WebParseDataBoundEx Function

Action

Parses the response data 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 (or after the last position of a previous search with) with maximum length 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. If nLeftOccurrence is greater than 1 (default is one) the sLeftBoundary has to be found nLeftOccurrence times, before the copy process starts and the right boundary is searched.

When verifying/parsing an HTML page that consists of multiple frames (HTML documents), you can specify which frame document to verify/parse by specifying the nDocNum parameter. By default (1) the top document (e.g. a frameset) is 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).

Note: This function can be added automatically to your script using the visual parsing functionality of TrueLog Explorer.

Include file

WebAPI.bdh

Syntax

WebParseDataBoundEx(out sResult        : string,
                    in  nMaxResultLen  : number optional,
                    in  sLeftBoundary  : string optional,
                    in  nLeftOccurrence : number optional,
                    in  sRightBoundary : string optional,
                    in  nOptions       : number optional,
                    in  nDocNum        : number 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 subsequent request. Note that nothing is parsed if the specified table is not loaded (cache hit).
WEB_FLAG_SYNCHRON
Parsing operations with this flag set, are done in a sequential way. The second parsing operation is not executed before the first has been completed.
WEB_FLAG_ALL_RESPONSES
If this flag is specified all server responses are scanned (even redirection responses, which are normally not displayed by a browser).
WEB_FLAG_INCLUDE_EMBEDDED
If this flag is specified, even embedded documents can be specified by the nDocNum parameter. Normally the number of a document is defined by the occurrence of the source definition in an HTML document (src=...). If this flag is specified, every embedded object increases this counter, which assigns higher numbers to subsequent frames.
WEB_FLAG_INCLUDE_HEADER
If this flag is specified the response header can also be verified.
WEB_FLAG_HEADER_ONLY
If this flag is specified only the response header is verified.
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!
nDocNum Specifies the document to parse (optional). Specify WEB_DOC_ALL if you want to parse all documents. If this parameter is omitted, the first document gets parsed. (see above definition FLAG_INCLUDE_EMBEDDED)
nBytesParsed Variable receiving the number of bytes actually parsed (optional).

Example

dcltrans
  transaction TMain
  var
    nResult: number;
    sFont: string;
    sResult: string;
  begin
    WebParseDataBoundEx(sResult, STRING_COMPLETE, "<table>", 2, "</table>");
    WebPageUrl("http://mycompany.com/");
    WebParseDataBoundEx(sFont,
STRING_COMPLETE, "<font>", 6, "</font>", WEB_FLAG_CASE_SENSITIVE |
WEB_FLAG_IGNORE_WHITE_SPACE);
    WebParseDataBoundEx(sResult, 200, "<b>Shop", 2,
"&amp;", WEB_FLAG_CASE_SENSITIVE, 2, nResult);
    WebUrl("http://mycompany.com/Shop/default.htm");
    Print(sFont);
    Print(sResult);
    Print(string(nResult) + "Bytes parsed");
  end TMain;