Indicates the number of items in the collection.
lValue = oXMLDOMNodeList.length;
The following script example creates an IXMLDOMNodeList object and then uses its length property to support iteration.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var objNodeList;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
var myErr = xmlDoc.parseError;
alert("You have error " + myErr.reason);
} else {
objNodeList = xmlDoc.getElementsByTagName("author");
for (var i=0; i<objNodeList.length; i++) {
alert(objNodeList.item(i).text);
}
}
lValue = oXMLDOMNodeList.length
The following Microsoft® Visual Basic® example creates an IXMLDOMNodeList object and then uses its length property to support iteration.
Dim xmlDoc As New Msxml2.DOMDocument50
Dim objNodeList As IXMLDOMNodeList
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 objNodeList = xmlDoc.getElementsByTagName("author")
For i = 0 To (objNodeList.length - 1)
MsgBox objNodeList.Item(i).Text
Next
End If
HRESULT get_length(
long *listLength);
listLength parameter is Null.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: IXMLDOMNodeList | IXMLDOMSelection