Skip to content

Commit

Permalink
Merge pull request #30 from dunnleaddress/master
Browse files Browse the repository at this point in the history
Fix for large XML files not being converted fully
  • Loading branch information
knadh committed Mar 23, 2016
2 parents 0a0cd3c + 6817011 commit a58d7be
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions xmlutils/xml2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ def __init__(self, input_file, output_file = None, encoding='utf-8'):

def get_json(self, pretty=True):
"""
Convert an XML file to json string
Convert an XML file to json string (Tested with python 2.7.8 on Windows 7)
Keyword arguments:
pretty -- pretty print json (default=True)
"""

self.context = iter(self.context)
event, root = self.context.next()
iterator = iter(self.context)

return self._elem2json(root, pretty)
try:
while True:
event, root = iterator.next()
except StopIteration:
print("Event StopIteration found, done!")
finally:
return self._elem2json(root, pretty)

def convert(self, pretty=True):
"""
Expand Down

0 comments on commit a58d7be

Please sign in to comment.