length Property (IXMLDOMNodeList)
Indicates the number of items in the collection.
[Script]
Script Syntax
lValue = oXMLDOMNodeList.length;
Example
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); } }
[Visual Basic]
Visual Basic Syntax
lValue = oXMLDOMNodeList.length
Example
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
[C/C++]
C/C++ Syntax
HRESULT get_length( long *listLength);
Parameters
- listLength [out, retval]
- The number of items in the collection.
C/C++ Return Values
- S_OK
- The value returned if successful.
- E_INVALIDARG
- The value returned if the
listLength
parameter is Null.
Remarks
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.
See Also
Applies to: IXMLDOMNodeList | IXMLDOMSelection