Skip to content
Browse files

fixed bad handling of cdata in semistructured xml, changed _CDATA_ to…

… #text as default
  • Loading branch information...
1 parent b3d3016 commit 6befd1a12bc99cf9fb56a0d6a193bdca2cbc1d5e @martinblech martinblech committed Apr 17, 2012
Showing with 4 additions and 3 deletions.
  1. +2 −2 README.markdown
  2. +2 −1 xmltodict.py
View
4 README.markdown
@@ -1,6 +1,6 @@
# xmltodict
-`xmltodict` is a Python module that makes working with XML feel like you are working with [JSON](http://docs.python.org/library/json.html):
+`xmltodict` is a Python module that makes working with XML feel like you are working with [JSON](http://docs.python.org/library/json.html), as specified in this ["spec"](http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html):
```python
>>> doc = xmltodict.parse("""
@@ -21,7 +21,7 @@ u'an attribute'
[u'elements', u'more elements']
>>> doc['mydocument']['plus']['@a']
u'complex'
->>> doc['mydocument']['plus']['_CDATA_']
+>>> doc['mydocument']['plus']['#text']
u'element as well'
```
View
3 xmltodict.py
@@ -9,7 +9,7 @@ def __init__(self,
xml_attribs=True,
item_callback=lambda *args: True,
attr_prefix='@',
- cdata_key='_CDATA_',
+ cdata_key='#text',
force_cdata=False):
self.path = []
self.stack = []
@@ -29,6 +29,7 @@ def startElement(self, name, attrs):
attrs = dict((self.attr_prefix+key, value)
for (key, value) in attrs.items())
self.item = self.xml_attribs and attrs or None
+ self.data = None
def endElement(self, name):
if len(self.path) == self.item_depth:

0 comments on commit 6befd1a

Please sign in to comment.
Something went wrong with that request. Please try again.