WebParseResponseTagContent Function

Action

Parses the HTML response and stores the HTML content or the raw HTML code in a string variable. The data in question can be specified by a tag, an attribute-value pair (which must be part of the tag), the name of the frame, and the nth appearance of these conditions.

Finding the data is not affected by the order of multiple calls to WebParseResponseTagContent or by calls to other parsing functions (like WebParseResponseTag, WebParseResponseData, and so on). The subsequent low-level web function will not return until the request has finished. Other requests started before may run in parallel.

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

Note: If you want to parse a Web server response, you must first call the WebParseResponseHeader function. Then you send the request to the Web server.

Include file

WebAPI.bdh

Syntax

WebParseResponseTagContent( out sResult       : string,
                            in  nMaxResultLen  : number,
                            in  sTag           : string,
                            in  sCondAttribute : string optional,
                            in  sCondValue     : string optional,
                            in  nAppearance    : number optional,
                            in  sFrame         : string optional,
                            in  bBaseDocOnly   : boolean optional,
                            in  bGetCode       : boolean optional,
                            out nResultLen     : number optional ): boolean;

Return value

  • true if the parsing modifier could be created successfully

  • false otherwise

Parameter Description
sResult String variable that receives the value of the specified attribute.
nMaxResultLen Maximum length of the string to return. This value must be less than or equal to the size of the string variable sResult.
sTag Tag whose content (or code) has to be returned.
sCondAttribute Attribute of the conditional attribute-value pair that must be present in the tag (optional). If this parameter is omitted, no conditional attribute-value pair is checked.
sCondValue Value of the conditional attribute-value pair that must be present in the result tag (optional).
nAppearance This parameter specifies which instance of the appearance when all conditions are met is the one for which the result is set (optional). If this parameter is omitted the first appearance is taken.
sFrame Frame name where to search (optional). If this parameter is omitted, the whole page is searched. An empty string specifies the top frame.
bBaseDocOnly If this parameter is set to TRUE, only the base document is searched. If sFrame specifies a frame set, the sub frames are not scanned (optional). If this parameter is omitted, all sub frames are searched also.
bGetCode If this parameter is TRUE the raw data between begin and end tags is returned. If this parameter is omitted only the content (what you see at the browser) of the specified tag is returned.
nResultLen Variable that receives the number of bytes actually copied to sResult (optional).

Example

dcltrans
  transaction TMain
  var
    sBody             : string(5000);
    sRawHead, sResult : string;
  begin
    WebParseResponseTagContent(sBody, STRING_COMPLETE, "body");
    WebPageUrl("http://mycompany.com/");
    WebParseResponseTagContent(sRawHead, STRING_COMPLETE, "head",
0, 0, 1, "", false, true);
    WebParseResponseTagContent(sResult,
STRING_COMPLETE, "font", "size", "5");
    WebUrl("http://mycompany.com/Shop/default.htm");
    Print(sBody);
    Print(sRawHead);
    Print(sResult);
  end TMain;