Allows random access to individual nodes within the collection.
var objXMLDOMNode = oXMLDOMNodeList.item(index);
An object. Returns IXMLDOMNode
. Returns Null if the index is out of range.
The following script example creates an IXMLDOMNodeList
object with the document's getElementsByTagName
method. It then iterates through the collection, displaying the text value of each item in the list.
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); } }
Set objXMLDOMNode = oXMLDOMNodeList.item(index)
An object. Returns IXMLDOMNode
. Returns Null if the index is out of range.
The following Microsoft® Visual Basic® example creates an IXMLDOMNodeList
object with the document's getElementsByTagName
method. It then iterates through the collection, displaying the text value of each item in the list.
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_item( long index, IXMLDOMNode **listItem);
IXMLDOMNode
. Returns Null if the index is out of range.listItem
parameter is Null.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