How to write reserve word in xml text part using python -
i tried write cdata xml, <
, >
change <
, >
. 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 "<![cdata[echo "something..."]]>"
i tried method such as
- using
xml.sax.saxutils.escape
,xml.sax.saxutils.unescape
- add
\
before<
,>
both methods not working.
thanks help.
Comments
Post a Comment