Skip to content

Commit

Permalink
failed to finish converting all xml elements.
Browse files Browse the repository at this point in the history
fix for issue knadh#20
  • Loading branch information
dunglehome committed Mar 22, 2016
1 parent 0a0cd3c commit c60fd1b
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(root2, pretty)

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

0 comments on commit c60fd1b

Please sign in to comment.