[lxml-dev] Efficient way to search element attribs?

Viksit Gaur vik.list.nutch at gmail.com
Sat May 24 12:43:14 CEST 2008


Hi all,

When building a tree, I add a particular attribute to each element (eg: 
ID), and was wondering if there are any methods I could use to search 
the tree for tags that have this attribute?

I looked at find(), findall() and the xpath functions - but they seem to 
help only when you know the tag name itself. Of course, one way might be 
  to do a manual depth first or breadth first search from the root 
downwards, recursively.. But that would become expensive pretty soon.

Thanks,
Viksit


More information about the lxml-dev mailing list