我有一个python脚本,该脚本接受一个json并使用所需的值生成一个xml。不幸的是,其中一个值具有CDATA标记,该标记被lxml.etree以某种方式转义。如何禁用它?
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'))
结果是
Desired:
<![CDATA[<b>hello</b>]]>
Desired:
<![CDATA[<b>hello</b>]]>
Not desired:
<![CDATA[<b>hello</b>]]>