+ 14
[solved] How to insert XML-element inside of text with Python?
I have the code https://code.sololearn.com/cmL7fthzIr2Q/?ref=app where I want to convert <my_element>hello my world</my_element> into <my_element>hello <red>my</red> world</my_element> by means of the xml.etree.ElementTree module. Is this possible at all, and if it is, how would I have to proceed with this?
6 Respostas
+ 1
Perhaps xsl would be the easiest and most suitable tool to deal with this, using regex in xsl:analyze-string?
You could still call saxon xsl processor from within your python script...
Or call etree.XSLT, for that matter.