Skip to content

Commit c2d1b43

Browse files
committed
[#151] Don't hardcode root element for XML->spreadsheet
1 parent 084608c commit c2d1b43

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

flattentool/json_input.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ def __init__(self, json_filename=None, root_json_dict=None, schema_parser=None,
6666

6767
if self.xml:
6868
with codecs.open(json_filename, 'rb') as xml_file:
69-
root_json_dict = xmltodict.parse(
69+
top_dict = xmltodict.parse(
7070
xml_file,
7171
force_list=(root_list_path,),
7272
force_cdata=True,
73-
)['iati-activities']
73+
)
74+
# AFAICT, this should be true for *all* XML files
75+
assert len(top_dict) == 1
76+
root_json_dict = list(top_dict.values())[0]
7477
json_filename = None
7578

7679
if json_filename is None and root_json_dict is None:

0 commit comments

Comments
 (0)