Partager via


removeAttributeNode Method

 

Removes the specified attribute from this element.

JScript Syntax

var objXMLDOMAttribute = oXMLDOMElement.removeAttributeNode(DOMAttribute);  

Parameters

DOMAttribute
An object that supplies the IXMLDOMAttribute object to be removed from this element.

Return Value

An object. Returns the removed element.

Example

Note

You can use books.xml to run this sample code.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var nodeBook, nodeId;
xmlDoc.setProperty("SelectionLanguage", "XPath");
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   nodeBook = xmlDoc.selectSingleNode("//book");
   nodeId = nodeBook.getAttributeNode("id");
   WScript.Echo(nodeBook.attributes.length);
   nodeBook.removeAttributeNode(nodeId);
   WScript.Echo(nodeBook.attributes.length);
}

Output

1

0

C/C++ Syntax

HRESULT removeAttributeNode(  
    IXMLDOMAttribute *DOMAttribute,  
    IXMLDOMAttribute **attributeNode);  

Parameters

DOMAttribute[in]
The DOMAttribute object that is to be removed from this element.

attributeNode[out, retval]
The removed element.

Return Values

S_OK
The value returned if successful.

E_FAIL
The value returned if an error occurs.

Remarks

If the attribute has a default value, this call also creates a new attribute with the default value, associates the new attribute with this element, and resets the attribute's specified property.

Versioning

Implemented in: MSXML 3.0 and lMSXML 6.0

See Also

specified Property
IXMLDOMAttribute
IXMLDOMElement