I want to use CallByName in VBA to read a specific data from such webpages. Those webpages have different html structures. In my case, there is a element that I need to refer 2 or 3 parent nodes and get an element with or tags. See the code:
element in all webpages I named MyElem
in one webpage I need this code:
MsgBox MyElem.parentElement.parentElement.parentElement.getelementsbytagname("tr")(3).innertext
in another webpage I need this code:
MsgBox MyElem.parentElement.parentElement.getelementsbytagname("div")(2).innertext
and so on ...
I want to write in VBA as below:
Select Case Webpage
Case "webpage_1"
property ="parentElement.parentElement.parentElement.getelementsbytagname("tr")(3).innertext"
Case "webpage_2"
property = "parentElement.parentElement.getelementsbytagname("div")(2).innertext"
' and so on ...
End Select
MsgBox CallByName(MyElem, property, VbGet)
The problem is that CallByName don't support multiple levels of properties. I read similar topic here but it doesn't help to my case. Is there any idea?