web.regSaveParamXpath

ExampleCorrelation Functions for JavaScript

Registers a request to save dynamic data in an HTML buffer that has been formatted as XML. The data is saved to a parameter.

Syntax

web.regSaveParamXpath( {object} ); 

JavaScript Object

{
    paramName: "<string>",
    queryString: "<string>",
    returnXML: "<string>",
    selectAll: "<string>",
    DFEs: "<string>",
    notFound: "<string>",
    contentType: "<string>",
    headerNames: "<string>",
    ignoreRedirections: "<string>",
    relFrameID: "<string>",
    requestURL: "<string>",
    scope: "<string>"
}
Property Name
Description
paramNameThe name of the parameter to create.
queryStringThe Xpath of the value to save.
returnXMLOptional: If "Yes", the data returned in the parameter specified by paramname includes the entire XML node at the specified Xpath, including contained elements. See the Example
selectAllOptional: If "Yes", all the occurrences of the match are saved in an array. See Saving Multiple Matches below in this topic.
DFEs Optional. Comma separated list of Data Formats extensions that are to be used before the required search operation is to be performed.
notFoundOptional. The handling option when the search item is not found and an empty string is generated. One of:
  • "error" - (default) Causes an error to be raised when a search item is not found.
  • "warning" - Does not issue an error. If the search item is not found, it sets the parameter count to 0, and continues executing the script. The "warning" option is ideal if you want to see if a string was found, but you do not want the script to fail.

Note: If Continue on Error is enabled for the script, then even when notFound is set to "error", the script continues when the search item is not found, but an error message is written to the Extended log file.

contentType For example, "text/html". Only responses with the specified contentType header are searched. The contentType can contain the * wildcard.
headerNames A comma-separated list of HTTP response header names. Only the specified headers' values are searched. This argument applies only when the scope is "Headers"
ignoreRedirections

If ignoreRedirections is "Yes" and the server response is redirection information (HTTP status code 300-303, 307), the response is not searched. Instead, after receiving a redirection response, the GET request is sent to the redirected location and the search is performed on the response from that location.

The default is "No".

relFrameID

The hierarchy level of the HTML page relative to the requested url. The possible values are ALL or a number. Click relframeid Attribute for a detailed description.

requestURLOnly responses to this request are searched. The URL can contain the * wildcard.
scopeOptional. Where to search for the delimited data. One of:
  • All - Search the entire buffer
  • Headers - Search only the headers
  • body - Search only body data (Default)
  • Cookies - Search only in cookies

Return Values

Not applicable

Parameterization

The values of keyword-value pairs can be parameterized. For example, "alt={altParam}".

General Information

web.regSaveParamXpath registers a request to find an XML node within the server response to the next action function and save the string. This function is used when the server response is XML or converted to XML. For example, the function is used in conjunction with Data Format extensions that output in XML format. The search does not apply to values returned as a result of calls to asynchronous or cross-step functions.

This function registers a request to retrieve dynamic information from the XML and save the information to a parameter. For correlation, enclose the parameter name in braces (e.g., "{param1}") in ensuing function calls which use the dynamic data. The request registered by web.regSaveParamXpath looks for the the node specified with the queryString argument and saves the contents of the node, if found. See also Correlating Statements.

For more information about XPATH, see XML Query or search the internet for XPATH.

Saving Multiple Matches

The web.regSaveParamXpath function supports array type parameters. When you specify selectAll:"Yes", all the occurrences of the match are saved in an array. Each element of the array is represented by the paramname_index. In the following example, the parameter name is A:

web.regSaveParamXpath( {paramName:"A", queryString:"//component/prd/item", selectAll:"Yes"} );

The first match is saved as A_1, the second match is saved as A_2, and so forth. You can retrieve the total number of matches by using the following term: paramname_count. For example, to retrieve the total number of matches saved to the parameter array, use:

TotalNumberOfMatches=atoi(lr.evalString("{A_count}"));

 

web.regSaveParamXpath is not recorded. You can add it manually to a script.

Restrictions

scope = ALL does not apply to web.regSaveParamXpath.

No searches are performed in data downloaded asynchronously.

If the headernames filter argument is specified but the scope is not Headers, the headernames argument is ignored.

If relframeid :"ALL" is specified, the ordinal argument must be omitted or set to ALL.

For more information on the DFEs argument, see Attributes for Save Parameter Registration Functions.

For more information on the headernames and scope arguments, see Search Filters for Save Parameter Registration Functions

For more information on the relframeid and selectAll arguments, see Search Filters for Save Parameter Registration Functions and relframeid Attribute.

Concept Link IconSee Also

Example

web.regSaveParamXpath({
   paramName:"outParam",
   queryString:"//tag_c",
   scope:"Body"
});