I have the following code snippet:
from xml.etree.ElementTree import fromstring,tostring mathml = fromstring(input) for elem in mathml.getiterator(): elem.tag = 'm:' + elem.tag return tostring(mathml)
When I enter the following input :
<math> <a> 1 2 3 </a> <b /> <foo>Uitleg</foo> </math>
This leads to:
<m:math> <m:a> 1 2 3 </m:a> <m:b /> <m:foo>Uitleg</m:foo> </m:math>
How did it happen? And how can I save a comment?
edit : I don't need the exact xml library, however I should be able to embed changes in tags. Unfortunately, lxml does not seem to allow this (and I cannot use the correct namespace operations)
source share