XML Parser
Hello Everyone,
Below is the XML Format:
<Cartons>
<Carton>
<SSCC18></SSCC18>
<TrackingNumber>XX</TrackingNumber>
<CartonContentsQty>X</CartonContentsQty>
<CartonWeight>0.200</CartonWeight>
<LineItems>
<LineItem>
<LineNumber>1</LineNumber>
<ItemNumber>XX</ItemNumber>
<UPC>XX</UPC>
<QTYOrdered>1</QTYOrdered>
<QTYShipped>1</QTYShipped>
<QTYUOM>EA</QTYUOM>
<Description></Description>
<Style></Style>
<Size></Size>
<Color></Color>
<RetailerItemNumber></RetailerItemNumber>
</LineItem>
</LineItems>
</Carton>
</Cartons>
The Above XML Transforms into JSON as:
"Cartons": {
"Carton": {
"SSCC18": {},
"TrackingNumber": "XXX",
"CartonContentsQty": "X",
"CartonWeight": "0.200",
"LineItems": {
"LineItem": {
"LineNumber": "1",
"ItemNumber": "XX",
"UPC": "XX",
"QTYOrdered": "X",
"QTYShipped": "X",
"QTYUOM": "EA",
"Description": {},
"Style": {},
"Size": {},
"Color": {},
"RetailerItemNumber": {}
}
}
}
}
If LineItems is single I am getting it as an Object.
If LineItems is multi-line I am getting it in an Array.
I want it to be an array for single Line Item.
In the XML Parser I see ListNodes as a field which can help me to achieve it.
Can anyone guide me how can I use that field?
Or Any other way to achieve it?
0
-
Hi Anek,
The ListNodes tell the parser which nodes should be considered as list and not single item, even if they are single item in the sample XML doc. In your case if you put "/Cartons/Carton/LineItems" in ListNodes, you will get the parsed JSON to have an array for LineItems :-
0
Please sign in to leave a comment.
Comments
1 comment