Need help getting child element using Excel XMLHTTP

前端 未结 1 1508
暗喜
暗喜 2020-12-22 03:37

I can successfully get all the \'games\' but can\'t then get the games details using the for each loop. I always get this error

object doesn\'t support this          


        
相关标签:
1条回答
  • 2020-12-22 04:13

    The getElementsByClassName method is a collection. If you want to refer to an individual item within the collection the minimum that you will have to provide is an integer for the zero-based index.

    Debug.Print game.getElementsByClassName("date")(0).innerText
    

    That will show the first element with a class of date within the game element (which is part of a collection itself).

    Alternately, cycle through them.

    for el = 0 to game.getElementsByClassName("date").length - 1
        Debug.Print game.getElementsByClassName("date")(el).innerText
    next el
    

    The .Length is a one-based count so you need to subtract 1 to match the zero-based index.

    0 讨论(0)
提交回复
热议问题