다음을 통해 공유


length Property (IXMLDOMNodeList)

 

Indicates the number of items in the collection.

Script Syntax

lValue = oXMLDOMNodeList.length;  

Example

The following script example creates an IXMLDOMNodeList object and then uses its lengthproperty to support iteration.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var objNodeList;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   objNodeList = xmlDoc.getElementsByTagName("author");
   for (var i=0; i<objNodeList.length; i++) {
      WScript.Echo(objNodeList.item(i).text);
   }
}

Visual Basic Syntax

lValue = oXMLDOMNodeList.length  

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.

Versioning

Implemented in:

MSXML 3.0, MSXML 6.0

Applies to

IXMLDOMNodeList | IXMLDOMSelection