I am working with an xml file which uses CDATA in some of the tags. I wish to edit the contents of CDATA but the ElementTree parser removes the CDATA from output xml
Sample input xml:
<question type="multichoice">
<name>
<text>decimal to binary 1</text>
</name>
<questiontext format="html">
<text><![CDATA[<p dir="ltr" style="text-align: left;">Convert the following number from decimal to binary:</p><p dir="ltr" style="text-align: left;">248<sub>10</sub></p>]]></text>
</questiontext>
<generalfeedback format="html">
<text></text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
...
This is a part of the xml input file. I wish to edit the CDATA in the text
tag to change the question and append this to an output xml file. How can I achieve this?
I tried some of the solutions from stackoverflow, but some of them were too convoluted to follow and didn't match my exact needs