
30 Sep
2014
30 Sep
'14
10:21 a.m.
Kun JIN schrieb am 30.09.2014 um 10:07:
"nsmap" is an lxml.element function to get namespaces of the element, usually, a None type will be returned, like:
{'olac': 'http://www.language-archives.org/OLAC/1.1/', None: 'http://www.imsglobal.org/xsd/imscp_v1p1%27%7D
i want use this namespaces in XPath, but i got an error: TypeError: empty namespace prefix is not supported in XPath
so, i must delete this NoneType by creating a new dictionay in Python:
dic_ns = {} for element in root.nsmap: if element is None: continue dic_ns[element] = root.nsmap[element]
QUESTION: is there some other methods to do this?
http://lxml.de/FAQ.html#how-can-i-find-out-which-namespace-prefixes-are-used...
And the one that follows.
Stefan