Share this page

# lr_xml_delete

XML Functions (lr_xml)

Deletes fragments from an XML string.

    int lr_xml_delete( <List of specifications> [, <List of optional specifications> ] [, LAST]);

List of specifications | For the following list of required specifications, use the following string format:"Specification=value" XML: the XML Input String to query ResultParam: the name of the output parameter containing the XML data after deleting the fragment. Query: the XML Query on the input string XML.
List of optional specifications | For the following list of optional specifications, use the following string format:"Specification=value" SelectAll: If "yes", all elements matching the query will be processed. If "no", only the first match will be processed. Default is "no". See Multiple Query Matching NotFound: See Continue on Error
LAST | A marker which indicates the end of the List of optional specifications

The lr_xml_delete function queries the XML input string XML and deletes the fragments of the XML tree that match the Query criteria. You can delete elements by specifying the element name or its attribute in the XMLquery. The output parameter ResultParam contains the modified XML string subsequent to deletion,using the source document encoding. The output preserves the XML Character Encoding of the original document, independent of the input encoding. The input encoding uses the client's local encoding.

Note: After deleting the contents of an element, the empty element, e, is signified <e/>. For example, the string result after deleting the element c from the XML string: "<a><b><c></c></b></a>"
is:
"<a><b/></a>"
since the element b is now empty.

## Return Values

See Return Values

## Parameterization

See Parameterization

## Example

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 Examples: common actions.

    #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 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: