Share this page

# web_reg_save_param_xpath

Correlation Functions for C

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

## C Language

    int web_reg_save_param_xpath( "ParamName=<output parameter name>", "QueryString=<Xpath>", ["ReturnXML=<Yes|No>",] ["SelectAll=<Yes|No>",] <List of Attributes>, <Search Filters>,LAST );

Argument | Description
--- | ---
The name of the parameter to create.
QueryString | The XPath of the value to save.
ReturnXML | Optional: If `ReturnXML=Yes`, the data returned in the parameter specified by ParamName includes the entire XML node at the specified XPath, including contained elements. If `ReturnXML=No`, only the value of the element that matches the query is returned. (Default)
SelectAll | Optional: If `SelectAll=Yes`, all the occurrences of the match are saved in an array. See Saving Multiple Matches below in this topic.
List of Attributes | For details of each attribute, see Attributes for Save Parameter Registration Functions. Attribute value strings (e.g., "Search=body") are not case-sensitive. See the Restrictions.
SEARCH FILTERS | Specifies the sections of the buffer to search for the string in. See Search Filters for Save Parameter Registration Functions. See Restrictions.
LAST | A marker that indicates the end of the argument list.

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

## Parameterization

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

## General Information

web_reg_save_param_xpath 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_reg_save_param_xpath 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_reg_save_param_xpath 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_reg_save_param_xpath("ParamName= A", "QueryString=//component/prd/item", "SelectAll=Yes", LAST );

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_eval_string("{A_count}"));`

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

## Restrictions

Scope = `ALL does not apply to` web_reg_save_param_xpath.

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 the RelFrameID=ALL argument 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.

## Example

The following examples show the use of web_reg_save_param_xpath.

    web_reg_save_param_xpath(
       "ParamName=outParam",
       "QueryString=//tag_c",
       SEARCH_FILTERS,
       "Scope=Body",
       LAST );

       web_url( "xpath_test.xml",
       "url=http://localhost/webgui/xpath_test.xml",
       LAST );

       lr_output_message( lr_eval_string( "outParam = {outParam}" ) );

Example with ReturnXML

This example shows the use of web_reg_save_param_xpath to return an entire XML segment.

    web_reg_save_param_xpath(
        "ParamName=CorrelationParameter",
        "QueryString=/LR_EXTENSION[1]/object[1]/object[1]/array[1]",
        "DFEs=JsonXml",
        "ReturnXML=Yes",
        SEARCH_FILTERS,
        "Scope=Body",
        LAST);

    web_url("generate_json_simple.asp",
        "URL=http://my_server/cgi-bin/json/generate_json_simple.asp",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://my_server/cgi-bin/json/json_correlation_base64.asp",
        "Snapshot=t2.inf",
        "Mode=HTML",
        LAST);

    lr_log_message(">>> CorrelationParameter = %s", lr_eval_string("{CorrelationParameter}"));

The output is:

>>> CorrelationParameter = <array name="batter"><object><pair type="str" name="id">1001</pair><pair type="str" name="type">Regular</pair></object><object><pair type="str" name="id">1002</pair><pair type="str" name="type">Chocolate</pair></object><object><pair type="str" name="id">1003</pair><pair type="str" name="type">Blueberry</pair></object><object><pair type="str" name="id">1004</pair><pair type="str" name="type">Devil's Food</pair></object></array>

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: