Forum Discussion
Thank you @del . This solution resolved my issue.
So let me put it differently now. Aside from my specific example and assuming that I have just to parse from XML to JSON and write it as-is without using any mapping/transformation to a JSON file to an external system but with the array format always enforced even with one element, Is there a way to do it in the XML parser by let us say for example checking the validate against XSD schema? Or do I have to use a mapper always to clean it and enforce the array on it?
The reason I am asking again because the XML I gave was just a simple example but in my real scenario the XML payload I am working in has more than a 100 elements and multiple nested array structure. so that means I have to use a mapper for each expected array in order to check it and use the [].concat[element] on it ?!
Hi,
Am also looking for solution for similar kind of issue with multiple elements having array structure, Did you find any solution in xml parser or added multiple mappers?
TIA,
Shruthi
- mohamadelmardin7 years agoNew Contributor III
@nshruthi
No I didn’t. Unfortunately SnapLogic doesn’t have an out-of-box solution in the XML parser to handle XML array transformation gracefully. I have an enhancement request opened with support but I haven’t heard any resolution on it yet and still waiting…Hi
I am new to SnapLogic. I need to use the Snap to parse XML file which has multiple elements and nested structure. Do you know where can I start to learn the XML parser or some Snaps? I found really limited resource available on Youtube, Google.
Regards,
Jim- mohamadelmardin7 years agoNew Contributor III
First you have to use the out-of-box XML parser snap and configuring it should be easy as described in SnapLogic documentation. Then the hard part begins after the incoming XML input parsed into JSON is to navigate through the nested structure and map any array or non-existing elements. The best way to do that is to use a series of Mapper snaps and in each mapper you have to use expression language statements which is a subset of JavaScript. To read more about expression language please check the following link:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438042/Expression+Language+OverviewFor example to cast an parsed XML element in JSON into an array type you would use the following expression: [].concat[ element ]
Please refer also to the beginning of this thread for other examples.
Even I too also facing the same issue. while flattening the multiple structure( both single child and multiple child elements) xml source to individual columns to target tables
Could anyone find any optimal solution for this?
I am using JSON Splitter and mapper snap but unable to find optimal solution and in-consistent for different structure of xml.
Please update here if anyone find solution for this.
Thanks,
Surendar
Related Content
- 6 months ago
- 11 months ago
- 2 years ago
- 4 years ago