Share this page

# Structure XML scripts

Initially, you create a new script in your preferred protocol. You can record a session in that protocol, or you may program the entire script without recording. Structure the Actions section of the script as follows:

- XML input declaration

- The Actions section

The XML input section contains the XML tree that you want to use as an input variable. You define the XML tree as a char type variable. For example:

    char *xml_input=
    "<acme_org>"
        "<employee>"
            " <name>John Smith</name>"
            "<cubicle>227</cubicle>"
            "<extension>2145</extension>"
        "</employee>"
        "<employee>"
            "<name>Sue Jones</name>"
            "<cubicle>227</cubicle>"
            "<extension>2375</extension>"
        "</employee>"
    "</acme_org>";

The Action section contains the evaluation of the variables and queries for the element values. In the following example, the XML input string is evaluated using lr_save_string. The input variable is queried for employee names and extensions.

    Action() {

        /* Save the input as a parameter.*/
        lr_save_string(xml_input, "XML_Input_Param");
        /* Query 1 - Retrieve an employee name from the specified element.*/
        lr_xml_get_values("XML={XML_Input_Param}",
            "ValueParam=OutputParam",
            "Query=/acme_org/employee/name", LAST);

        /* Query 2 - Retrieve an extension under any path below the root.*/
        lr_xml_get_values("XML={XML_Input_Param}",
            "ValueParam=OutputParam",
            "Query=//extension", LAST);

        return 0;
    }

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1-26.3 All View Local Help Center View Online Help Center Version: