0

I have a python script which takes a json and generates an xml with the values that I need. Unfortunately one of the values has CDATA tag which is escaped somehow by lxml.etree. How do I disable it?

import lxml.etree as ET

print ("Desired:")
print (ET.tostring(string_res, encoding='utf-8', method='xml'))
string_res.text = ''
string_res.text = value['Value']

print ("Desired:")
print string_res.text

print ("Not desired:")
print (ET.tostring(string_res, encoding='utf-8', method='xml'))

result is

Desired:
<![CDATA[<b>hello</b>]]>

Desired:
<![CDATA[<b>hello</b>]]>

Not desired:
&lt;![CDATA[&lt;b&gt;hello&lt;/b&gt;]]&gt; 
Nikola
  • 890
  • 1
  • 11
  • 35
  • 1
    Possible duplicate of https://stackoverflow.com/questions/174890/how-to-output-cdata-using-elementtree – amanb Mar 15 '19 at 13:02
  • 1
    Possible duplicate of [How to output CDATA using ElementTree](https://stackoverflow.com/questions/174890/how-to-output-cdata-using-elementtree) – Jacques Gaudin Mar 15 '19 at 14:09

0 Answers0