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= 
        " <name>John Smith</name>"
        "<name>Sue Jones</name>"         "<cubicle>227</cubicle>"

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;

Back to top