Microsoft XML 2.5 SDK


 

IXMLDOMNamedNodeMap::get_length Method

[This is preliminary documentation and subject to change.]

Indicates the number of items in the collection.

Visual Basic Syntax

lValue = oXMLDOMNamedNodeMap.length

C/C++ Syntax

HRESULT get_length(

    long *listLength);

Parameters

listLength

[out]
Number of items in the collection.

C/C++ Return Values

S_OK

Value returned if successful.

E_INVALIDARG

Value returned if listLength is null.

C/C++ Example

IXMLDOMNode *pIXMLDOMNode = NULL;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap = NULL;
IXMLDOMElement *pIXMLDOMElement = NULL;
long lLength;
TCHAR strTemp[10];
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->get_length(&lLength);
         if(SUCCEEDED(hr))
         {
            _itot(lLength, strTemp, 10);
            ::MessageBox(NULL, strTemp, _T("Number of Attributes"), MB_OK);
         }
         pIXMLDOMNamedNodeMap->Release();
         pIXMLDOMNamedNodeMap = NULL;
      }
      pIXMLDOMElement->Release();
      pIXMLDOMElement = NULL;
   }
}
catch(...)
{
   if(pIXMLDOMElement)
      pIXMLDOMElement->Release();
   if(pIXMLDOMNamedNodeMap)
      pIXMLDOMNamedNodeMap->Release();
   DisplayErrorToUser();
}
// Release pIXMLDOMDocument when done with it.