Home Search

DriveWorks Pro 21
SppXPathRemoveAttribute

Send Feedback

SppXPathRemoveAttribute

Returns an XML object with specified attribute(s) removed.

Syntax

SppXPathRemoveAttribute([XML],[Element Path],[Attribute Name])

Where:

XML is an XML object such as that returned from SppXMLFromString or SppXMLLoad, or XML as a text string.

Element Path is a full path to the element inside the XML object (for example Quote\Customer). If the element is part of an array with the same name, the path would need to use an instance number (for example Quote\Customer[6] to return the value for the sixth item. Element Path is case sensitive.

Attribute Name is the name of the attribute to be removed, if left blank or "" is used then all attributes will be removed.

Example

RuleResultMeaning
SppXPathRemoveAttribute(DWVariableXML,"CustomerInformation\Entry[2]\Details","Website")See Example Data and Example Result below.Will return an XML object with the specified attribute removed for the given element path.

Example Data

Example data showing customer data

<?xml version="1.0" encoding="UTF-8"?>
  <CustomerInformation>
    <Entry>
      <Customer>Smith Garage</Customer>
      <Details Website="www.fixmycar.co.uk"/>
    </Entry>
    <Entry>
      <Customer>Nuts and Bolts Brewing Co</Customer>
      <Details Website="nutsandboltsbrews.co.uk"/>
    </Entry>
    <Entry>
      <Customer>FlowersBuckets</Customer>
      <Details Website="FlowerBucket.co.uk"/>
    </Entry>
  </CustomerInformation>
        

Example Result

Example result showing the details attribute value removed for the second instance.

{"<CustomerInformation>
  <Entry>
    <Customer>Smith Garage</Customer>
    <Details Website=""www.fixmycar.co.uk"" />
  </Entry>
  <Entry>
    <Customer>Nuts and Bolts Brewing Co</Customer>
    <Details />
  </Entry>
  <Entry>
    <Customer>FlowersBuckets</Customer>
    <Details Website=""FlowerBucket.co.uk"" />
  </Entry>
</CustomerInformation>"}