Indicates the number of items in the collection.
lValue = oXMLDOMNamedNodeMap.length;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0"); var nodeBook, namedNodeMap; xmlDoc.setProperty("SelectionLanguage", "XPath"); xmlDoc.async = false; xmlDoc.load("books.xml"); if (xmlDoc.parseError.errorCode <> 0) { var myErr = xmlDoc.parseError; alert("You have error " + myErr.reason); } else { nodeBook = xmlDoc.selectSingleNode("//book"); namedNodeMap = nodeBook.attributes; alert(namedNodeMap.length); }
lValue = oXMLDOMNamedNodeMap.length
Dim xmlDoc As New Msxml2.DOMDocument50 Dim nodeBook As IXMLDOMElement Dim namedNodeMap As IXMLDOMNamedNodeMap xmlDoc.setProperty "SelectionLanguage", "XPath" xmlDoc.async = False xmlDoc.Load "books.xml" If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else Set nodeBook = xmlDoc.selectSingleNode("//book") Set namedNodeMap = nodeBook.Attributes MsgBox namedNodeMap.length End If
HRESULT get_length( long *listLength);
listLength
is Null.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 finished with it.
Long integer. The property is read-only.
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
Applies to: IXMLDOMNamedNodeMap