for reasons I won't bore you with, I am using a scriptcontrol JScript object in VBA to retrieve a webpage. I do this as follows (in 32bit Excel, for 64bit I use a MSHTA work-around).
Sub Test()
Dim S as Object
Set S = CreateObject("ScriptControl")
S.Language = "JScript"
S.Eval("var x = new ActiveXObject('MSXML2.XMLHTTP');")
S.Eval("x.open('GET', 'https://stackoverflow.com/', false);")
S.Eval("x.Send")
End Sub
Now this works fine and the returning response is in x.ResponseText, but how can I parse this in a HTML Document from which I can get specific document elements? JScript = ES3 and doesn't have DOMParser, jquery or the standard document.whatever.
I added John Resig's pure javascript HTML parser from https://johnresig.com/blog/pure-javascript-html-parser/ and while I can add the code (S.Addcode), it errors on me when using HTMLToDom;
S.AddCode JohnsCode
S.Eval ("var d = new ActiveXObject('HTMLFile');")
S.Eval ("HTMLToDom(x.ResponseText, d);") <-- this errors.
Am I missing something obvious here or is parsing a HTML response into a HTML Document where I can retrieve specific elements not possible in JScript/ES3?
Thanks for your help!