Page 1 of 1

XML to either CSV or API call?

Posted: Thu Feb 09, 2023 2:26 pm
by w.bromley
Hi Guys!

Long story short - I need to be able to take an XML file and use the data contained to either create an API call or generate a CSV that can be picked up by an external hotfolder.

The XML contains order information from EFI's online storefront which we need to use to trigger a job creation within our new MIS.

I haven't ever looked into this kind of thing before - any help would be greatly appreciated...

Thanks in advance.

Will

Re: XML to either CSV or API call?

Posted: Thu Feb 09, 2023 3:53 pm
by magnussandstrom
You need the Metadata Module in Switch to do this.

This is a flow thats starts with an XML pickup and three different outputs of choice:
flow_xml.png
flow_xml.png (37 KiB) Viewed 3032 times

XML pickup (metadata is asset) = This app "picks up" the XML and makes the different XML-values available for Switch (as metadata) so you can use that data downstream.
HTTP request = API communication
Create file from template = A free app where you can create CSV-files
CSV Creator = A paid app to create CSV-files


XML pickup (metadata is asset) "picks up" the XML and make the different values available for Switch (as metadata) so you can use that data for the output.

I hope this points you in the right direction

Re: XML to either CSV or API call?

Posted: Thu Feb 09, 2023 4:26 pm
by w.bromley
Ahhh brilliant! I didnt even think about using the metadata pickup to do this... (yeah I know - i'm still learning as I go).

I have picked up the XML and can see it as metadata to reference - great!

How can I handle this if there are more than one "items" that have been ordered and so multiple order nodes in the XML? If that makes sense?

Re: XML to either CSV or API call?

Posted: Thu Feb 09, 2023 5:38 pm
by magnussandstrom
w.bromley wrote: Thu Feb 09, 2023 4:26 pm How can I handle this if there are more than one "items" that have been ordered and so multiple order nodes in the XML? If that makes sense?
If you need to separate the order items (before sending them to the MIS) you can use XSLT transform (for that you need to configurate an XSL-file that suits you needs). Or take the short route and buy any of the XML apps thats avaliable in App-store, maybe Variable XPath Repeater or similar.

But the best approach (if possible) might be to send the whole job (including all order items) with API to the MIS. The MIS documentation should have a section what different options you have.

Re: XML to either CSV or API call?

Posted: Thu Feb 09, 2023 5:45 pm
by w.bromley
Hi!

Thanks for your help on this!

Managed to bodge an existing XLST app and mapping we have for something else...

Splits the order nodes out into individual XML files which I can then use downstream for API calls :)

Thanks again for your help!!!!!