Share this page

# lr.xmlDelete

Deletes fragments from an XML string.

JavaScript XML Functions (lr.xml)

## Syntax

    lr.xmlDelete( {object} );

## JavaScript Object

    {
        xml:"<string>",
        resultParam:"<string>",
        query:"<string>",
        selectAll:"<string>",
        notFound:"<string>"
    }

Property Name | Description
--- | ---
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.
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 Continuing on Error

The lr.xmlDelete 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 XML Query. 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

All XML functions return the number of matches successfully found or zero on failure.

## Parameterization

Input parameters to XML functions with the following names can be parameterized:

- XML

- Query

- Value

- XmlFragment

## Example

    function Action(){
       var xmlInput =
           "<acme_org>"+
           "<accounts_dept>" +
           "<employee>" +
           " <name>John Smith</name>" +
           "<cubicle>227</cubicle>" +
           "<extension>2145</extension>" +
           "</employee>" +
           "</accounts_dept>" +
           "</acme_org>";

           lr.saveString(xmlInput, "XML_Input_Param"); // Save input as parameter

       lr.xmlDelete({
             xml: '{XML_Input_Param}',
             resultParam : 'Result',
             query: '/acme_org/accounts_dept/employee/extension'
        });

        lr.outputMessage(lr.evalString("String after deletion: {Result}"));

    return 0;
    }

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: