Split tag and namespace in lxml

by , under python

I was using the target parser method of lxml as suggested here and could not turn off fully qualified name for tags and so wrote quick one to split namespace from tag name…

[sourcecode language=”python”]
def _gettagns(self,tag):
""" returns a tuple of namespace,name """

if tag[:1] == "{":
return tag[1:].split("}", 1)

return (None,tag)

Leave a Reply