IXMLDOMElement::removeAttribute Method [This is preliminary documentation and subject to change.]
Removes or replaces the named attribute.
Visual Basic Syntax
oXMLDOMElement.removeAttribute(name)
C/C++ Syntax
HRESULT removeAttribute(
BSTR name);
Parameters
name
[in]
Name of the attribute to be removed or replaced.
C/C++ Return Values
S_OK
Value returned if successful.
S_FALSE
Value when returning null.
E_FAIL
Value returned if an error occurs.
Remarks
If the specified attribute has a default value, this is equivalent to a replace operation: the current value is removed and a new attribute is created with the default value. This operation also resets the IXMLDOMNode interface's specified property.
C/C++ Example
IXMLDOMElement *pIXMLDOMElement = NULL;
_bstr_t bstrAttributeName = _T("dateCreated");
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;
hr = pIXMLDOMElement->removeAttribute(bstrAttributeName);
if(SUCCEEDED(hr))
{
// Attribute removed
}
pIXMLDOMElement->Release();
pIXMLDOMElement = NULL;
// release pIXMLDOMDocument after done with it
}
catch(...)
{
// release pIXMLDOMDocument if it exists
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
DisplayErrorToUser();
}