Reputation: 11715
I have a TextEdit widget in PyQt that I use to print out a log in HTML. I use HTML so I can separate entries into color categories (red for error, yellow for debug, blue for message, etc), but this creates a problem. Most of the debug messages are XML. When I use appendHtml on the widget, it strips out all the tags.
How can I pretty print XML in an HTML document?
Upvotes: 0
Views: 509
Reputation: 223172
cgi.escape
can help you. It will convert the characters '&'
, '<'
and '>'
in the string to HTML-safe sequences. That is enough to prevent interpretation of xml tags.
>>> cgi.escape('<tag>')
'<tag>
Upvotes: 4
Reputation: 392070
A cdata section might help.
http://reference.sitepoint.com/javascript/CDATASection
http://en.wikipedia.org/wiki/CDATA
Upvotes: 0