summaryrefslogtreecommitdiffstats
path: root/Lib/xml/dom/minidom.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xml/dom/minidom.py')
-rw-r--r--Lib/xml/dom/minidom.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 1beae0c..81a1330 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -301,9 +301,10 @@ def _in_document(node):
def _write_data(writer, data):
"Writes datachars to writer."
- data = data.replace("&", "&amp;").replace("<", "&lt;")
- data = data.replace("\"", "&quot;").replace(">", "&gt;")
- writer.write(data)
+ if data:
+ data = data.replace("&", "&amp;").replace("<", "&lt;"). \
+ replace("\"", "&quot;").replace(">", "&gt;")
+ writer.write(data)
def _get_elements_by_tagName_helper(parent, name, rc):
for node in parent.childNodes: