pattern = re.compile('^[A-Za-z0-9-]+$')
tags = path.split('/')
for i in range(len(tags)):
    if pattern.match(tags[i]):
        tags[i] = '{%s}%s' % (namespace, tags[i])
return '/'.join(tags)
Is Python bad at XML?