[lxml-dev] ElementTree.find does not accept QName objects.
John Krukoff
jkrukoff at ltgc.com
Fri Mar 28 21:30:51 CET 2008
Since I was the one that complained about the find method on Elements
not accepting QNames, it's probably not surprising that I expected them
to work with the ElementTree find method as well. Instead an unsliceable
error is thrown, due to the value being expected to be a string:
>>> from lxml import etree
>>> x = etree.XML( '<a><b/></a>' )
>>> e = etree.ElementTree( x )
>>> e.find( 'b' )
<Element b at b7f4d914>
>>> e.find( etree.QName( 'b' ) )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "etree.pyx", line 508, in etree._ElementTree.find
TypeError: 'etree.QName' object is unsliceable
Though using e.getroot( ).find is working fine as a workaround for me.
--
John Krukoff <jkrukoff at ltgc.com>
Land Title Guarantee Company
More information about the lxml-dev
mailing list