I have an html file that contains many "var"s in a section delimited by "<!--";
<!--
var g_stickyTableHeadersScrollVersion=1;... ;var g_priceListInfo={...,"arrProducts":[{"name":"...","type":"...","arrVariants":[{"name":"...","priceGroup":"..."},{"name":"...","priceGroup":"..."},...,{"name":"...","defaultSlabSize":[...,...],"priceGroup":"..."}],{"name":"...","price":...,"isSlabPricing":1}]}...}
-->
I'm at loss as to how to get the arrProducts
array of g_priceListInfo
variable values
After many (really a lot of) different attempts I thought I could use querySelector
method of HTMLDocument
as follows:
Dim url As String
url = "C:\Users\...\myHTMLFile.html"
Dim oFSO As FileSystemObject
Dim oFS As Object, sText As String
Set oFSO = New FileSystemObject ' CreateObject("Scripting.FileSystemObject")
Set oFS = oFSO.OpenTextFile(url)
Do Until oFS.AtEndOfStream
sText = oFS.ReadAll()
Loop
Dim doc As HTMLDocument
Set doc = CreateObject("htmlfile")
doc.body.innerHTML = sText
Dim ele As Object
Set ele = doc.querySelector("g_priceListInfo.arrProducts.name")
but, provided that is the right path, I couldn't find the correct syntax to make it work
thanks in advance for any help
EDIT: adding the relevant html page code view snapshots
EDIT 19/08/2022: I finally made it by means of a brute force string manipulation Then I found the no-ScriptControl & no-GitHub JSon parser solution at this link, which gave me the same results of my brute force method
I'd point everybody with the same need as this one of mine to that solution