Microsoft XML SDK 2.6 - XML Reference

IXMLDOMNamedNodeMap::removeQualifiedItem Method

Removes the attribute with the specified namespace and attribute name.

Visual Basic Syntax

Set objXMLDOMNode = oXMLDOMNamedNodeMap.removeQualifiedItem(baseName, 
    namespaceURI)

C/C++ Syntax

HRESULT removeQualifiedItem(
    BSTR baseName,
    BSTR namespaceURI,
    IXMLDOMNode **qualifiedItem);

Parameters

baseName [in]
Base name of the attribute, without namespace qualification.
namespaceURI [in]
Namespace prefix that qualifies the attribute name.
qualifiedItem [out]
Attribute node removed, or Null if no node was removed.

C/C++ Return Values

S_OK
Value returned if successful.
S_FALSE
Value when returning Null.
E_FAIL
Value returned if an error occurs.

C/C++ Example

IXMLDOMNode *pIXMLDOMNode = NULL;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap = NULL;
BSTR bstrAttributeName = ::SysAllocString(_T("dateModified"));
IXMLDOMElement *pIXMLDOMElement = NULL;
VARIANT varValue;
HRESULT hr;
IXMLDOMDocument *pIXMLDOMDocument = NULL;

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->get_attributes(&pIXMLDOMNamedNodeMap);
      if(SUCCEEDED(hr) && pIXMLDOMNamedNodeMap)
      {
         hr = pIXMLDOMNamedNodeMap->removeQualifiedItem(bstrAttributeName,             NULL, &pIXMLDOMNode);
         if(SUCCEEDED(hr) && pIXMLDOMNode)
         {
            pIXMLDOMNode->get_nodeValue(&varValue);
            ::MessageBox(NULL, _bstr_t(varValue), _T("Removed Item"),                   MB_OK);
            pIXMLDOMNode->Release();
            pIXMLDOMNode = NULL;
         }
         pIXMLDOMNamedNodeMap->Release();
         pIXMLDOMNamedNodeMap = NULL;
      }
      pIXMLDOMElement->Release();
      pIXMLDOMElement = NULL;
   }
   ::SysFreeString(bstrAttributeName);
   bstrAttributeName = NULL;
}
catch(...)
{
   if(bstrAttributeName)
      ::SysFreeString(bstrAttributeName);
   if(pIXMLDOMElement)
      pIXMLDOMElement->Release();
   if(pIXMLDOMNamedNodeMap)
      pIXMLDOMNamedNodeMap->Release();
   if(pIXMLDOMNode)
      pIXMLDOMNode->Release();
   DisplayErrorToUser();
}
// Release pIXMLDOMDocument when finished with it.

See Also

IXMLDOMNamedNodeMap Interface