Forum Discussion
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
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+Overview
For 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.
When you trigger a pipeline with a POST, the body is passed into the pipeline as an input document. So you can’t pass pipeline parameters per se, but you can still parameterize the snap fields off of the input document.
You can pass the bearer token in the Authorization header to avoid passing that in the URI as well.
- dwhansen-cbg6 years agoContributor
Ohhh. The body is passed as a document. That would explain it. So the only way to pass in parameters is to pass them in the URI?
The only other option is to pass them through headers.
- dwhansen-cbg6 years agoContributor
Is there a benefit to using custom headers over URI parameters?
Not from SnapLogic’s point of view. I’d say it’s more of a API design choice. I guess one difference is that the JCC will log the URI (
jcc_access.log
), so if there were parameters you didn’t want logged out, it’d be better to use a header. Otherwise, I think it’s a matter of taste.
Related Content
- 11 months ago
- 10 months ago
- 3 years ago