Skip to main content

DeleteAttribute

Deletes an attribute from the XML node at the specified XPath.

Syntax

expression.DeleteAttribute(xPath, name);

expression - A variable that represents a ApiCustomXmlPart class.

Parameters

NameRequired/OptionalData typeDefaultDescription
xPathRequiredstringThe XPath of the node from which to delete the attribute.
nameRequiredstringThe name of the attribute to delete.

Returns

boolean

Example

Delete an attribute from a custom XML part element in a spreadsheet.

// How to delete the attribute for a custom XML part in a spreadsheet?

// Delete the attribute and display the result in a spreadsheet.

const worksheet = Api.GetActiveSheet();
const xmlManager = worksheet.GetCustomXmlParts();
const xmlString = "<config version='1.0' namespace='http://example' />";
const xml = xmlManager.Add(xmlString);

xml.DeleteAttribute('/config', 'namespace');
worksheet.GetRange('A1').SetValue('XML after deletion: ' + xml.GetXml());