consider the following example
div > h1 > p > a
div.children()
gives the immediate children which is h1
of course i use find('*')开发者_如何学Go
to get all descendants.
however, i need div.find( h1 > p > a)
not div.find(h1,p,a)
, which is what the default find('*') is doing: it is simply ignoring the original hiearchy.
please note that div can be anything. the whole hiearchy can vary in depth. ie) div > h1 > span > b > i > a and etc....
I'm not entirely sure what you mean, but have you tried ancestor descendant instead of parent > child (you mention that your hierarchy can be of any depth, parent > child will only look for immediate children):
div.find('h1 p a')
精彩评论