diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-11-18 15:36:07 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-11-18 15:36:07 (GMT) |
commit | def4728fd65535c0502fc7e8297d99aead7568a2 (patch) | |
tree | 624494840efeaa92d4d850cb10e5a1dfdc1e13cd /Lib/xml | |
parent | 4d5d4e28557d2afb00d04b649fb58c62b7e51995 (diff) | |
parent | 8008f2aba0c063a882c33ebd4b39a5a560deb8c0 (diff) | |
download | cpython-def4728fd65535c0502fc7e8297d99aead7568a2.zip cpython-def4728fd65535c0502fc7e8297d99aead7568a2.tar.gz cpython-def4728fd65535c0502fc7e8297d99aead7568a2.tar.bz2 |
#4147: merge with 3.2.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/minidom.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 386494d..f23ad05 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -837,11 +837,15 @@ class Element(Node): writer.write("\"") if self.childNodes: writer.write(">") - if self.childNodes[0].nodeType != Node.TEXT_NODE: + if (len(self.childNodes) == 1 and + self.childNodes[0].nodeType == Node.TEXT_NODE): + self.childNodes[0].writexml(writer, '', '', '') + else: writer.write(newl) - for node in self.childNodes: - node.writexml(writer,indent+addindent,addindent,newl) - writer.write("%s</%s>%s" % (indent,self.tagName,newl)) + for node in self.childNodes: + node.writexml(writer, indent+addindent, addindent, newl) + writer.write(indent) + writer.write("</%s>%s" % (self.tagName, newl)) else: writer.write("/>%s"%(newl)) @@ -1063,7 +1067,7 @@ class Text(CharacterData): return newText def writexml(self, writer, indent="", addindent="", newl=""): - _write_data(writer, self.data) + _write_data(writer, "%s%s%s" % (indent, self.data, newl)) # DOM Level 3 (WD 9 April 2002) |