xml-to-array icon indicating copy to clipboard operation
xml-to-array copied to clipboard

Two child nodes with same name

Open mattiasghodsian opened this issue 4 years ago • 2 comments

When using parseXml( ); and the XML file has for example two node child's with similar names one of them gets replaced instead of getting grouped together

<?xml version="1.0" encoding="UTF-8"?>
<cbc:ID>1616</cbc:ID>
<OrderResponse>
	<cac:OrderLine>
		<cac:LineItem>
			<cbc:ID>1</cbc:ID>
		</cac:LineItem>
		<cac:OrderLineReference>
			<cbc:LineID>1.00</cbc:LineID>
		</cac:OrderLineReference>
	</cac:OrderLine>
	<cac:OrderLine>
		<cac:LineItem>
			<cbc:ID>2</cbc:ID>
		</cac:LineItem>
		<cac:OrderLineReference>
			<cbc:LineID>2.00</cbc:LineID>
		</cac:OrderLineReference>
	</cac:OrderLine>
</OrderResponse>

mattiasghodsian avatar Aug 05 '20 11:08 mattiasghodsian

This behavior is to be expected. When you're working with arrays and you have two same-level keys with the same name, the second one will overwrite the first.

mtownsend5512 avatar Aug 05 '20 14:08 mtownsend5512

This behavior is to be expected. When you're working with arrays and you have two same-level keys with the same name, the second one will overwrite the first.

Could you make it merge similar keys as nested-array?

mattiasghodsian avatar Aug 11 '20 13:08 mattiasghodsian