Re: Ignoring XML Namespaces with cElementTree

2010-05-01 Thread dmtr
> Unless you have multiple namespaces or are working with defined schema > or something, it's useless boilerplate. > > It'd be a nice feature if ElementTree could let users optionally > ignore a namespace, unfortunately it doesn't have it. Yep. Exactly my point. Here's a link to the patch address

Re: Ignoring XML Namespaces with cElementTree

2010-05-01 Thread Stefan Behnel
Carl Banks, 01.05.2010 12:33: On Apr 29, 10:12 pm, Stefan Behnel wrote: dmtr, 30.04.2010 04:57: I don't want these "{http://www.very_long_url.com}"; in front of my tags. They create performance disaster on large files I seriously doubt that they do. I don't know what kind of XML files you

Re: Ignoring XML Namespaces with cElementTree

2010-05-01 Thread Carl Banks
On Apr 29, 10:12 pm, Stefan Behnel wrote: > dmtr, 30.04.2010 04:57: > > > > > I'm referring to xmlns/URI prefixes. Here's a code example: > >   from xml.etree.cElementTree import iterparse > >   from cStringIO import StringIO > >   xml = """http://www.very_long_url.com";> > root>""" > >   for even

Re: Ignoring XML Namespaces with cElementTree

2010-05-01 Thread Carl Banks
On Apr 27, 6:42 pm, dmtr wrote: > Is there any way to configure cElementTree to ignore the XML root > namespace?  Default cElementTree (Python 2.6.4) appears to add the XML > root namespace URI to _every_ single tag.  I know that I can strip > URIs manually, from every tag, but it is a rather idio

Re: Ignoring XML Namespaces with cElementTree

2010-04-30 Thread Stefan Behnel
dmtr, 30.04.2010 23:59: I think that's your main mistake: don't remove them. Instead, use the fully qualified names when comparing. Yes. That's what I'm forced to do. Pre-calculating tags like tagChild = "{%s}child" % uri and using them instead of "child". Exactly. Keeps you from introducing

Re: Ignoring XML Namespaces with cElementTree

2010-04-30 Thread dmtr
Here's a link to the patch exposing this parameter: http://bugs.python.org/issue8583 -- http://mail.python.org/mailman/listinfo/python-list

Re: Ignoring XML Namespaces with cElementTree

2010-04-30 Thread dmtr
> I think that's your main mistake: don't remove them. Instead, use the fully > qualified names when comparing. > > Stefan Yes. That's what I'm forced to do. Pre-calculating tags like tagChild = "{%s}child" % uri and using them instead of "child". As a result the code looks ugly and there is extra

Re: Ignoring XML Namespaces with cElementTree

2010-04-29 Thread Stefan Behnel
dmtr, 30.04.2010 04:57: I'm referring to xmlns/URI prefixes. Here's a code example: from xml.etree.cElementTree import iterparse from cStringIO import StringIO xml = """http://www.very_long_url.com";>""" for event, elem in iterparse(StringIO(xml)): print event, elem The output is: endh

Re: Ignoring XML Namespaces with cElementTree

2010-04-29 Thread dmtr
I'm referring to xmlns/URI prefixes. Here's a code example: from xml.etree.cElementTree import iterparse from cStringIO import StringIO xml = """http://www.very_long_url.com";>""" for event, elem in iterparse(StringIO(xml)): print event, elem The output is: end http://www.very_long_url.com}ch

Re: Ignoring XML Namespaces with cElementTree

2010-04-28 Thread Stefan Behnel
dmtr, 28.04.2010 03:42: Is there any way to configure cElementTree to ignore the XML root namespace? Default cElementTree (Python 2.6.4) appears to add the XML root namespace URI to _every_ single tag. Certainly not in the serialised XML. Are you referring to the qualified names it uses? St

Ignoring XML Namespaces with cElementTree

2010-04-27 Thread dmtr
Is there any way to configure cElementTree to ignore the XML root namespace? Default cElementTree (Python 2.6.4) appears to add the XML root namespace URI to _every_ single tag. I know that I can strip URIs manually, from every tag, but it is a rather idiotic thing to do (performance wise). -- h