[This is preliminary documentation and subject to change.]
Removes the specified attribute from this element.
Visual Basic Syntax
Set objXMLDOMAttribute = oXMLDOMElement.removeAttributeNode(DOMAttribute)
C/C++ Syntax
HRESULT removeAttributeNode(
IXMLDOMAttribute *DOMAttribute,
IXMLDOMAttribute **attributeNode);
Parameters
DOMAttribute
[in]
DOMAttribute object that is to be removed from this element.
attributeNode
[out]
Removed element.
C/C++ Return Values
S_OK
Value returned if successful.
E_FAIL
Value returned if an error occurs.
Remarks
Note that if the attribute has a default value, this call also creates a new attribute object with the default value, associates the new attribute with this element, and resets the attribute's specified property.
C/C++ Example
IXMLDOMElement *pIXMLDOMElement = NULL;
_bstr_t bstrAttributeName = _T("dateCreated");
IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
IXMLDOMAttribute *pRemovedIXMLDOMAttribute = NULL;
IXMLDOMDocument *pIXMLDOMDocument = NULL;
HRESULT hr;
try
{
// create an instance of DOMDocument and initialize pIXMLDOMDocument
// load/create an XML fragment
hr = pIXMLDOMDocument->get_documentElement(&pIXMLDOMElement);
SUCCEEDED(hr) ? 0 : throw hr;
if(pIXMLDOMElement)
{
hr = pIXMLDOMElement->getAttributeNode(bstrAttributeName, &pIXMLDOMAttribute);
if(SUCCEEDED(hr) && pIXMLDOMAttribute)
{
hr = pIXMLDOMElement->removeAttributeNode(pIXMLDOMAttribute, &pRemovedIXMLDOMAttribute);
if(SUCCEEDED(hr))
// Attribute Node removed
bResult = TRUE;
pIXMLDOMAttribute->Release();
}
pIXMLDOMElement->Release();
}
// release pIXMLDOMDocument after done with it
}
catch(...)
{
// release pIXMLDOMDocument if it exists
if(pIXMLDOMAttribute)
pIXMLDOMAttribute->Release();
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
DisplayErrorToUser();
}