Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue18304] ElementTree -- provide a way to ignore namespace in tags and seaches

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Aug 11, 2013, 9:05 AM

Post #1 of 5 (25 views)
Permalink
[issue18304] ElementTree -- provide a way to ignore namespace in tags and seaches

Eli Bendersky added the comment:

I was planning to look more closely at the namespace support in ET at some point, but haven't found the time yet.

[changing the title to be more helpful]

----------
title: ElementTree gets awkward to use if there is an xmlns -> ElementTree -- provide a way to ignore namespace in tags and seaches

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 11, 2013, 9:17 AM

Post #2 of 5 (23 views)
Permalink
[issue18304] ElementTree -- provide a way to ignore namespace in tags and seaches [In reply to]

Stefan Behnel added the comment:

There's also the QName class which can be used to split qualified tag names. And it's pretty trivial to pre-process the entire tree by stripping all namespaces from it the intention is really to do namespace agnostic processing. However, in my experience, most people who want to do that haven't actually understood namespaces (although, admittedly, sometimes it's those who designed the XML format who didn't understand namespaces ...).

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 11, 2013, 10:41 AM

Post #3 of 5 (21 views)
Permalink
[issue18304] ElementTree -- provide a way to ignore namespace in tags and seaches [In reply to]

Eli Bendersky added the comment:

> (although, admittedly, sometimes it's those who designed the XML format
who didn't understand >namespaces ...).

I fully concur. The design of XML, in general, is not the best
demonstration of aesthetics in programming. But namespaces always seem to
me to be one further step in the WTF direction. This is precisely why I
didn't reject this issue right away: perhaps it's not a bad idea to provide
Python programmers with *some* way to ease namespace-related tasks (even if
they go against the questionable design principles behind XML).

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 11, 2013, 9:21 PM

Post #4 of 5 (17 views)
Permalink
[issue18304] ElementTree -- provide a way to ignore namespace in tags and seaches [In reply to]

Stefan Behnel added the comment:

Please leave the title as it is now.

----------
title: ElementTree gets awkward to use if there is an xmlns -> ElementTree -- provide a way to ignore namespace in tags and seaches

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 11, 2013, 9:34 PM

Post #5 of 5 (16 views)
Permalink
[issue18304] ElementTree -- provide a way to ignore namespace in tags and seaches [In reply to]

Stefan Behnel added the comment:

As I already suggested for lxml, you can use the QName class to process qualified names, e.g.

QName(some_element.tag).localname

Or even just

QName(some_element).localname

It appears that ElementTree doesn't support this. It lists the QName type as "opaque". However, it does provide a "text" attribute that contains the qualified tag name.

http://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.QName

Here is the corresponding documentation from lxml:

http://lxml.de/api/lxml.etree.QName-class.html

QName instances in lxml provide the properties "localname", "namespace" and "text".

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.