xml.sax.saxutils

The xml.sax.saxutils module defines some utility functions and objects that may be useful when writing SAX-based XML parsers.

escape(data [, entities])

Given a string, data, this function replaces certain characters with escape sequences. For example, ‘<’ gets replaced by ‘&lt;’. entities is an optional dictionary that maps characters to the escape sequences. For example, setting entities to { u’\xf1’ : ‘&ntilde;’ } would replace occurs of ñ with ‘&ntilde;’.

unescape(data [, entities])

Unescapes special escape sequences that appear in data. For instance, ‘&lt;’ is replaced by ‘<’. entities is an optional dictionary mapping entities to unescaped character values. entities is the inverse of the dictionary used with escape()—for ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.