@@ -549,8 +549,9 @@ def unflatten_main_with_parser(parser, line, timezone, xml, id_name):
549
549
if current_type and current_type != 'array' :
550
550
raise ValueError ("There is an array at '{}' when the schema says there should be a '{}'" .format (path_till_now , current_type ))
551
551
list_index = int (next_path_item )
552
+ current_type = 'array'
552
553
553
- if isint ( next_path_item ) or current_type == 'array' :
554
+ if current_type == 'array' :
554
555
list_as_dict = current_path .get (path_item )
555
556
if list_as_dict is None :
556
557
list_as_dict = ListAsDict ()
@@ -564,7 +565,10 @@ def unflatten_main_with_parser(parser, line, timezone, xml, id_name):
564
565
new_path = OrderedDict ()
565
566
list_as_dict [list_index ] = new_path
566
567
current_path = new_path
567
- continue
568
+ if not xml or num < len (path_list )- 2 :
569
+ # In xml "arrays" can have text values, if they're the final element
570
+ # This corresponds to a tag with text, but also possibly attributes
571
+ continue
568
572
569
573
## Object
570
574
if current_type == 'object' or (not current_type and next_path_item ):
@@ -578,7 +582,7 @@ def unflatten_main_with_parser(parser, line, timezone, xml, id_name):
578
582
break
579
583
current_path = new_path
580
584
continue
581
- if current_type and current_type != 'object' and next_path_item :
585
+ if current_type and current_type not in [ 'object' , 'array' ] and next_path_item :
582
586
raise ValueError ("There is an object or list at '{}' but it should be an {}" .format (path_till_now , current_type ))
583
587
584
588
## Other Types
@@ -607,7 +611,9 @@ def unflatten_main_with_parser(parser, line, timezone, xml, id_name):
607
611
if path_item .startswith ('@' ):
608
612
current_path [path_item ] = cell
609
613
else :
610
- if path_item not in current_path :
614
+ if current_type == 'array' :
615
+ current_path ['text()' ] = cell
616
+ elif path_item not in current_path :
611
617
current_path [path_item ] = {'text()' : cell }
612
618
else :
613
619
current_path [path_item ]['text()' ] = cell
0 commit comments