跳到主要内容

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

This example shows how to delete an attribute from a custom XML part element.

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());