ncikic
unread,Dec 10, 2012, 11:07:28 PM12/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python-...@googlegroups.com
I am new to xml processing in python.
I am looking to create XML. Xml is not too difficult so I thought to create it manually using ElementTree.
First I noted that ET.toString does escape <>& but not " and '
Is that normal?
Since I have also the need to sing the XML I need the ability to create xml but without xml escaping (unescaped data are signed).
If i do ET.toString(root,'utf8',text') i do not get the xml tags and if I do ET.toString(root,'utf8') I get escaped chars.
For example:
a=ET.Element('a')
b=ET.SubElement(a,'b')
b.text=u"šđ<>&"
ET.tostring(a,'utf8')
outputs to
"<?xml version='1.0' encoding='utf8'?>\n<a><b>\xc5\xa1\xc4\x91<>&</b></a>"
ET.tostring(a,'utf8',method='text')
outputs to
"\xc5\xa1\xc4\x91<>&"
and I need before singing
<a><b>\xc5\xa1\xc4\x91<>&</b></a>
and after signing
<a><b>\xc5\xa1\xc4\x91<>&</b></a>
Is there some way other than string replace?
Thanks
Nenad