[lxml-dev] iterparse and namespaces
Piotr Furman
piotr.furman at webservice.pl
Tue Mar 17 14:39:11 CET 2009
Hi,
I've got small problem with iterparse and namespaces. I have this code:
>>> from StringIO import StringIO
>>> from lxml import etree
>>> print etree.__version__
2.1.5
>>> xml = """<root xmlns="http://www.example.com"><a>1</a><a>2</a></root>"""
>>> a1 = etree.iterparse(StringIO(xml), tag="a")
>>> a1.next()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "iterparse.pxi", line 515, in lxml.etree.iterparse.__next__
(src/lxml/lxml.etree.c:77014)
StopIteration
>>> a2 = etree.iterparse(StringIO(xml), tag="{http://www.example.com}a")
>>> a2.next()
(u'end', <Element {http://www.example.com}a at -488456c4>)
Is that possible to get all tags "a" without passing namespace? I mean, a2
works, but could it be possible to make a1 working too?
regards
Piotr Furman
More information about the lxml-dev
mailing list