Share this page

# Example: lr_xml_delete

The following example searches the input string xml_input for the tag "<extension>" and deletes it. The resulting string is contained in the ResultParam parameter, Result.

For more examples of the use of lr_xml_delete, see Deleting elements in Example Scripts for XML Queries.

    #include "as_web.h"

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

    Action() {

        lr_save_string(xml_input, "XML_Input_Param"); // Save input as parameter

        lr_xml_delete("XML={XML_Input_Param}",

            "ResultParam=Result",

            "Query=/acme_org/accounts_dept/employee/extension",

            LAST );

        lr_output_message(lr_eval_string("String after deletion: {Result}"));

        return 0;

    }

Example: Output:
Action.c(25): String after deletion: <acme_org><accounts_dept><employee> <name>John Smith</name><cubicle>227</cubicle></employee> </accounts_dept></acme_org>

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