Retrieves the named attribute node.
Visual Basic Syntax
Set objXMLDOMAttribute = oXMLDOMElement.getAttributeNode(name)
C/C++ Syntax
HRESULT getAttributeNode(
BSTR name,
IXMLDOMAttribute **attributeNode);
Parameters
name
[in]
Name of the attribute to be retrieved.
attributeNode
[out]
DOMAttribute object that is returned with the supplied name, or NULL if the named attribute cannot be found on this element.
C/C++ Return Values
S_OK
Value returned if successful.
S_FALSE
Value when returning null.
E_INVALIDARG
Value returned if name is null.
C/C++ Example
BOOL DOMElementAttributeNode()
{
BOOL bResult = FALSE;
BSTR bstrAttributeName = ::SysAllocString(_T("dateCreated"));
IXMLDOMAttribute* pIXMLDOMAttribute = NULL;
IXMLDOMElement *pIXMLDOMElement = 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(m_hr) ? 0 : throw hr;
If(pIXMLDOMElement)
{
hr = pIXMLDOMElement->getAttributeNode(bstrAttributeName, &pIXMLDOMAttribute);
if(SUCCEEDED(hr) && pIXMLDOMAttribute)
{
// read node value and display . . .
bResult = TRUE;
pIXMLDOMAttribute->Release();
pIXMLDOMAttribute = NULL;
}
::SysFreeString(bstrAttributeName);
bstrAttributeName = NULL;
pIXMLDOMElement->Release();
}
}
catch(...)
{
if(bstrAttributeName)
::SysFreeString(bstrAttributeName);
if(pIXMLDOMAttribute)
pIXMLDOMAttribute->Release();
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
DisplayErrorToUser();
}
return bResult;
}