How to write reserve word in xml text part using python -


i tried write cdata xml, < , > change &lt; , &gt;. how can correctly write cdata xml file?

here parts of code.

script = '<![cdata[echo "something..."]]>' xroot = etree.parse(xmlfile) xpath = '//a:profile/a:scripts/a:post-scripts/a:script/a:source' code = xmlroot.xpath(xpath) code[0].text = script 

the result "&lt;![cdata[echo "something..."]]&gt;"

i tried method such as

  • using xml.sax.saxutils.escape , xml.sax.saxutils.unescape
  • add \ before < , >

both methods not working.

thanks help.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -