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

Tim Chambers report at bugs.python.org
Thu Nov 2 04:33:30 EDT 2017


Tim Chambers <tygrus78 at gmail.com> added the comment:

I suggest adding the option to keep the namespace prefixes in the tree when reading in (will it need to set a tree wide variable for the instance?). I haven't looked at the etree internals in detail.

Add a function to ElementTree that returns the tag using the namespace prefix (eg. treenode.tagpre). Namespaces and prefixes are cached and used to expand the prefix only when absolutely required. Some XML/xpath search operations currently assume the full expanded namespaces not prefixes which may lead to side-effects.
You can leave the default behaviour for compatibility.
Using prefixes in the tree storage and searches would reduce memory and CPU time (when no expansion is required).

----------
nosy: +Tim Chambers

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue18304>
_______________________________________


More information about the Python-bugs-list mailing list