WebParseResponseData Function

Action

Parses the response data (commonly HTML) for sLeftBoundary and sRightBoundary and stores the string between these boundaries in sResult. This modifier can be used in many situations. One of the most common is retrieving state information out of hidden form field values. When the right delimiter (sRightBoundary) is not specified (set to NULL), the string after sLeftBoundary with length nMaxResultLen is returned. When the left delimiter (sLeftBoundary) is not specified (set to NULL), the string from beginning or after the last position of a previous search with maximum length nMaxResultLen is returned. When both boundary search strings are omitted (sLeftBoundary and sRightBoundary are set to NULL), all data with maximum length is stored into sResult.

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: The order of multiple calls to WebParseResponseData affects finding the parameters. The subsequent low-level web function will NOT return until the request has finished. Other requests started before may run in parallel. This parsing is optimized for speed. For more complex parsing you can use this function to retrieve the whole document and parse it yourself using the string functions.
Note: If you want to parse a Web document, you must first call the WebParseResponseData function. Then you call the function which retrieves the document.
Note: This function is obsolete. It can still be used, although it's recommended to use the WebParseDataBound function instead.

Include file

WebAPI.bdh

Syntax

WebParseResponseData( out sResult        : string,
                      in  nMaxResultLen  : number,
                      in  sLeftBoundary  : string optional,
                      in  sRightBoundary : string optional,
                      out nBytesParsed   : number optional ): boolean;

Return value

  • true if the parsing modifier could be created successfully

  • false otherwise

Parameter Description
sResult String variable that receives the string between the specified boundary strings.
nMaxResultLen Maximum length of the string to return. This value must be less than or equal to the size of the string variable sResult.
sLeftBoundary Left boundary string of the value to search for (optional). Passing a NULL value will store all the document data (like HTML) into sResult.
sRightBoundary Right boundary string of the value to search for (optional). Passing a NULL value will store all the document data (like HTML) after the occurrence of sLeftBoundary into sResult.
nBytesParsed Variable receiving the number of bytes actually parsed (optional).

Example

dcltrans
  transaction TWeb
  var
    sTitle           : string(100);
    sHiddenSessionID : string(100);
begin
    // Check for an error message set in the HTML title.
    // (Note: the HTTP response error should be set to a
    // value > 200!! See HTTP specifications)
    WebParseResponseData(sTitle, sizeof(sTitle),
                         "<title>", "</title>");

    // our session info has a fixed size of 11 characters
    WebParseResponseData(sHiddenSessionID, 11, "name=\"SessionID\""
                         "value=\"");
    WebUrl("http://standardhost/", 0.0);
    write(sTitle); writeln;
    write(sHiddenSessionID); writeln;
  end TWeb;

Sample scripts

WebFileUpload01.bdf, WebMultiIpAddresses01.bdf, WebRegularExpressions01.bdf, WebSecure02.bdf