I have downloaded the below code from a website (Sory i can't remember name of the site) while i searching for the method to scrape website data using xpath. However this code gives Runtime error 91 & debugging shows the line
Debug.Print ResultList.Item(i).nodeName
I have enabled Microsoft internet controls, Microsoft HTML object library & Microsoft XML v6. My Version of excel is 2010.Could yolu please let me know why i'm getting this error.
Code
Sub GetData()
Dim objhttp As Object
Dim XMLDatei As String
Dim ResultList As IXMLDOMNodeList
Dim i As Integer
Dim counter As Integer
Dim xml As New DOMDocument
Dim XPathQuery As String
Dim url As String
Dim XPath As String

XPathQuery = "/html/body/div[2]/div/div/div/main/article/div/h1"
url = "http://www.whatismyip.com"

Set objhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    objhttp.Open "GET", url, False
    objhttp.send ("")

xml.Load xmlsource:=objhttp.responseText
xml.setProperty Name:="SelectionLanguage", Value:="XPath"

Set ResultList = xml.SelectNodes(XPathQuery)
counter = ResultList.Length
Range("A1") = counter
For i = 0 To counter
If Not ResultList Is Nothing Then
    Debug.Print ResultList.Item(i).nodeName
End If
Next i
End Sub