def register_prefix(self, nspair):
"""
Register with ElementTree a set of namespaces
:param nspair: A dictionary of prefixes and uris to use when
constructing the text representation.
:return:
"""
for prefix, uri in nspair.items():
try:
ElementTree.register_namespace(prefix, uri)
except AttributeError:
# Backwards compatibility with ET < 1.3
ElementTree._namespace_map[uri] = prefix
except ValueError:
pass
评论列表
文章目录