Hi,
Could someone tell me why the 1st code works but the 2nd doesn't? Both should print out "2" as the result yet only the first one does.
Thanks for looking
Could someone tell me why the 1st code works but the 2nd doesn't? Both should print out "2" as the result yet only the first one does.
Thanks for looking
Code:
Sub get_commonShips()
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
IE.Visible = True
IE.navigate "https://robertsspaceindustries.com/pledge/ship-upgrades"
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Set HTMLDoc = IE.document
'===============================================================================
Dim Buttons As MSHTML.IHTMLElementCollection ' find & click "Choose a ship"
'---------------------------------------------------
Set Buttons = HTMLDoc.getElementsByClassName("choose-ship js-choose-ship")
Debug.Print Buttons.Length
'===============================================================================
End Sub
Code:
Sub get_commonShips_XML()
Dim XMLPage As New MSXML2.XMLHTTP60
Dim HTMLDoc As New MSHTML.HTMLDocument
XMLPage.Open "GET", "https://robertsspaceindustries.com/pledge/ship-upgrades", False ' {False: replaces wait loop}
XMLPage.send
HTMLDoc.body.innerHTML = XMLPage.responseText
'===============================================================================
Dim Buttons As MSHTML.IHTMLElementCollection ' find & click "Choose a ship"
'---------------------------------------------------
Set Buttons = HTMLDoc.getElementsByClassName("choose-ship js-choose-ship")
Debug.Print Buttons.Length
'===============================================================================
End Sub