diff --git a/tests/test_xmltodict.py b/tests/test_xmltodict.py index 037771e..7dd22b5 100644 --- a/tests/test_xmltodict.py +++ b/tests/test_xmltodict.py @@ -93,13 +93,13 @@ def test_skip_whitespace(self): """ self.assertEqual( parse(xml), - {'root': {'emptya': " ", + {'root': {'emptya': None, 'emptyb': {'@attr': 'attrvalue'}, 'value': 'hello'}}) def test_keep_whitespace(self): xml = " " - self.assertEqual(parse(xml), dict(root=' ')) + self.assertEqual(parse(xml), dict(root=None)) self.assertEqual(parse(xml, strip_whitespace=False), dict(root=' ')) diff --git a/xmltodict.py b/xmltodict.py index cca2dae..b903798 100755 --- a/xmltodict.py +++ b/xmltodict.py @@ -123,7 +123,7 @@ def endElement(self, full_name): else self.cdata_separator.join(self.data)) item = self.item self.item, self.data = self.stack.pop() - if self.strip_whitespace and data and item: + if self.strip_whitespace and data: data = data.strip() or None if data and self.force_cdata and item is None: item = self.dict_constructor()