One of my subelements of my xml file has to contain a HTML code snippet eg.:
import import xml.etree.ElementTree as ET
.
.
.
qtext = ET.SubElement(questiontext, 'text')
qtext.text = '<![CDATA[<div class="qtext"></div>]]>'
I define several other elements during the process. At the end I save with:
tree._setroot(quiz)
tree.write("quiz.xml", encoding="UTF-8", xml_declaration=True)
The snippet in the exported XML file looks like:
<text><![CDATA[<div class="qtext"></text>
Instead of:
<text><![CDATA[<div class="qtext"></text>
I have a working XML file as a standard example. My job is to copy it's structure. This is the reason why I have to include the HTML snippet. The file will be imported into Moodle.