WebParseDataBoundArray Function

Action

Parses the response data for sLeftBoundary and sRightBoundary and stores all strings between these boundaries in saResult. If the right delimiter (sRightBoundary) is not specified (set to NULL), every nMaxLen (must be specified) bytes after the occurrences of sLeftBoundary are returned. In contrary the WebParseDataBoundEx function the second left boundary is only searched after the right boundary has been found or, if the right boundary parameter is omitted, nMaxLen bytes after the occurrence of the first left boundary.

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 (for example 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).

Include file

WebAPI.bdh

Syntax

WebParseDataBoundArray( inout saResult       : array of string,
                        in    nMaxCount      : number,
                        in    sLeftBoundary  : string,
                        in    sRightBoundary : string allownull,
                        out   nFound         : number optional,
                        in    nOptions       : number optional,
                        in    nSkip          : number optional,
                        in    nDocNum        : number optional,
                        in    nMaxLen        : number optional);
Parameter Description

saResult

Array of string variable that receives all the strings between the specified boundary strings.

nMaxCount

Maximum number of strings copied into the provided array. This value must be less than or equal to the size of the array.

sLeftBoundary

Left boundary to compare.

sRightBoundary

Right boundary. After the sLeftBoundary has been found, all data is copied into the actual string parameter until the right boundary is found (optional). If this parameter is omitted the nMaxLen parameter must be specified.

nFound

Variable that receives the number of the found strings (optional).

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_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, you must use global variables. Call WebCancelAllRules() to disable all verification and parsing rules.
重要: The option WEB_FLAG_RULE should only be used in the INIT transaction or in combination with the WebCancelAllRules function.

nSkip

Specifies the number of parse results that should not be stored in the array (optional). The first element of the array will be the parse-result number nSkip+1.

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

nMaxLen

Specifies the maximum number of bytes copied to each string (optional). If the sRightBoundary parameter is omitted, this parameter must be specified and determines the end of every parsing operation.

Example

transaction TWeb
  var
    sa, sa1         : array[10] of string;
    nFound, nFound1 : number;
    i               : number;
  begin
    WebParseDataBoundArray(sa, 10, "<!--", "-->", nFound);
    WebParseDataBoundArray(sa1,
10, "Begin", null, nFound1, 0, 0, 0, 5); //5 bytes
    WebPageUrl("http://lab3");

    print("found " + string(nFound) + " comments");
    print("found " + string(nFound1) + " Begin... statements");
    for i:= 1 to nFound do
      print(sa[i]);
    end;
    for i:= 1 to nFound1 do
      print(sa1[i]);
    end;
  end TWeb;