0

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?

2 Answers 2

4

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>')
'&lt;tag&gt;
Sign up to request clarification or add additional context in comments.

Comments

0

A cdata section might help.

http://reference.sitepoint.com/javascript/CDATASection

http://en.wikipedia.org/wiki/CDATA

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.