From 8066e3a4ef2f8323d0f8fac3764fb960fb611ea4 Mon Sep 17 00:00:00 2001 From: Jon Friskics Date: Wed, 3 Apr 2013 16:15:02 -0400 Subject: [PATCH] convert & to & when CDATA is removed, and & to & when it is put back --- indentxml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indentxml.py b/indentxml.py index f31637f..f1d6f57 100644 --- a/indentxml.py +++ b/indentxml.py @@ -88,12 +88,12 @@ def indent(self, s): # convert to plain string without indents and spaces s = re.compile(b'>\s+([^\s])', re.DOTALL).sub(b'>\g<1>', s) # replace tags to convince minidom process cdata as text - s = s.replace(b'', b'%CDATAEEND%') + s = s.replace(b'', b'%CDATAEEND%') s = parseString(s).toprettyxml() # remove line breaks s = re.compile('>\n\s+([^<>\s].*?)\n\s+\g<1>') + s = s.replace('%CDATAESTART%', '') # remove xml header s = s.replace("", "").strip() if xmlheader: