Forum Discussion

mohamadelmardin's avatar
mohamadelmardin
New Contributor III
9 years ago

Parsing XML Array to JSON array is inconsistent

When using XML parser snap to parse XML documents we are facing a problem when handling XML array type. This is because XML parser parses XML Array at runtime to either a JSON array if the particular element in the incoming XML message comes as array or as a single JSON object/element if the particular element in the incoming XML message comes as a single element not as an array. This is causing a major problem down the processing pipeline especially when using Mapper or any similar snaps where the parsed JSON data comes either as an array or as element {} and pipeline breaks for error.

The question is how can we force XML parser or combine it with any other technique so that it will parse XML element to JSON always as an array even if it comes as a single XML array element. Attached is an example of a simple pipeline reading an xml file with attached schema xsd. If the XML item element cames as an array then the pipeline will process successfully til the tend but if it comes as a single item then it will definitely fails at Mapper because JSON cannot treat it as an array
ParsingXMLArray_2017_07_24.slp (4.5 KB)
shippingtestingschema.xsd.txt (1.2 KB)
shiporder.xml.txt (673 Bytes)
shiporder_OneItem.xml.txt (527 Bytes)

8 Replies

No RepliesBe the first to reply