WebParseTable Function

Action

Parses HTML tables and stores the content of the specified cell in the provided string. A subsequent low-level web function will not return a value until the request has finished.

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

WebParseTable( out sResult       : string,
               in  nMaxResultLen : number,
               in  nTablenNum    : number,
               in  nRow          : number,
               in  nColumn       : number,
               in  nOptions      : number optional,
               in  sFrame        : string optional,
               out nBytesParsed  : number optional);

Return value

  • none

Parameter Description
sResult String variable that receives the content of the specified cell.
nMaxResultLen Maximum length of the string to return. Set this parameter to STRING_COMPLETE all available data is stored in sResult.
nTableNum The nTableNum th table is parsed.
nRow Specifies the row of the cell to parse.
nColumn Specifies the column of the cell to parse.
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_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).
sFrame Frame that gets searched for the specified table (optional). If this parameter is omitted the whole page is scanned.
nBytesParsed Variable receiving the number of the bytes that actually parsed (optional).

Example

dcltrans
  transaction TMain
  var
    sResult  : string;
    sResult1 : string;
    nResult  : number;
  begin
    WebParseTable(sResult, STRING_COMPLETE, 2, 3, 4);
    WebPageUrl("http://mycompany.com/");
    Print(sResult);

    WebParseTable(sResult,
STRING_COMPLETE, 2, 1, 2, WEB_FLAG_DONT_FORCE_LOAD); // sResult can be ""
    WebUrl("http://mycompany.com/Shop/default.htm");
    Print(sResult);

    WebParseTable(sResult, STRING_COMPLETE, 2, 2, 2);
    WebParseTable(sResult, 
STRING_COMPLETE, 3, 2, 3, 0, "FrameB", nResult);
    WebPageUrl("http://mycompany.com/frame/framea.html");
    Print(sResult);
    Print(sResult1);
    Print(string(nResult) + "Bytes parsed");
  end TMain;