[XML-SIG] Extend of cDomlette DOM API support

Alexandre Alexandre.Fayolle@logilab.fr
Thu, 13 Jun 2002 09:17:20 +0200


On Wed, Jun 12, 2002 at 08:37:07PM -0700, L. C. Rees wrote:

> One convienient method, getElementsByTagName, isn't present. Are there 
> plans to do this sometime in the near future? Is there a substitute?

You can use XPath which will allow you to get a more precise control of
the search. 

Assuming doc is a cDomlette document, you can use

from Ft.Xml.XPath import Evaluate
nodes = Evaluate('//tag',doc)


Or if you only want the 'tag' nodes that are children of the root
element (and not all 'tag' nodes in the document):

nodes = Evaluate('/*/tag',doc)

which will be much faster (since it avoids searching the whole tree).

Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).