Removing NS in ElementTree

Stefan Behnel stefan.behnel-n05pAM at web.de
Sat May 26 02:00:15 EDT 2007


Sebastian Bassi wrote:
> I would like to remove the namespace information from my elements and
> have just the tag without this information. This
> "{http://uniprot.org/uniprot}" is preapended into all my output.

  for el in root.getiterator():
      if el.tag[0] == '{':
          el.tag = el.tag.split('}', 1)[1]


That should do the job.

Stefan



More information about the Python-list mailing list