HTML DOM traversal using Treewalker in VBA
If I create an IE application object in VBA, I can download webpages and also use the document
property to call functions like getElementById
. However, I wanted DOM traversal capabilities desperate开发者_JAVA技巧ly.
The documentation defines a treeWalker
object which looks very promising but I am just not able to make createTreeWalker
work. I am getting an object required
error at the function call to createTreeWalker
. Has anybody used this method or can somebody point me to an example where treeWalker
has been used through VBA?
It seems that TreeWalker has not been implemented until at least IE9 (which my employer does not provide unfortunately). However, I still managed DOM traversal using the following properties:
.childNodes(x) 'x begins at 0
.parentNode
.nextSibling
.innerHTML
These properties apply to almost any node which getElementById()
might throw up and these are implemented in earleir IE versions as well.
精彩评论