[lxml-dev] how knowing the types return by .xpath
Stefan Behnel
stefan_ml at behnel.de
Thu Feb 5 09:14:36 CET 2009
Sergio Monteiro Basto wrote:
> isinstance(lxml.etree._ElementUnicodeResult, basestring) is true
> and
> isinstance(xml.etree._Element, basestring) is false
>
> which resolve my initial problem
>
> but what instance is xml.etree._Element ?
etree.iselement(an_element)
is True for elements, but also for PIs, comments and entities (if you
configured the parser to leave entities in).
isinstance(element.tag, basestring)
is True only for Elements (and entities, IIRC).
Stefan
More information about the lxml-dev
mailing list