Following on from my initial comment.
The selectNodes() method returns a IXMLDOMNodeList object which is a NodeList collection.
As with any collection it contains members common to collection objects
Properties
length - Number of Nodes in the collection
Methods
item - Access to individual Nodes within the collection
For full list of member properties and methods see
IXMLDOMNodeList
Members
There should be no logical reason why you need to change your For Each to a For loop as you can just use the length property to retrieve the number of Nodes in the collection.
Option Explicit
Dim node, nodes, li, i, sXPath, NumberOfNodes
Set nodes = objMSXML.selectNodes(sXPath)
'Retrieve number of Nodes
NumberOfNodes = nodes.length
For Each node In nodes
Set li = document.createElement("li")
li.innerText = i & " " & node.text
ul.appendChild li
i = i +1
Next
Useful Links
Forinstead of aFor Each? If it's because you want to workout the number of nodes you don't need to theIXMLDOMNodeListis a collection so just use thelengthproperty like thisNumOfNodes = objMSXML.selectNodes(sXPath).lengthto retrieve the number of nodes.