lr.xmlDelete

Deletes fragments from an XML string.

ExampleXML Functions (LR_XML)

Syntax

lr.xmlDelete( {object} );
        

JavaScript Object

{
    xml:"<string>",
    resultParam:"<string>",
    query:"<string>",
    selectAll:"<string>",
    notFound:"<string>"
} 
Property Name
Description
xmlThe XML Input String to query.
resultParamThe name of the output parameter containing the XML data after deleting the fragment.
queryThe XML Query on the input string XML.
selectAllIf "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.
notFoundSee 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;
}