XML to either CSV or API call?

Post Reply
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

XML to either CSV or API call?

Post 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
User avatar
magnussandstrom
Advanced member
Posts: 355
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: XML to either CSV or API call?

Post 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 767 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
Last edited by magnussandstrom on Fri Feb 10, 2023 10:39 am, edited 3 times in total.
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

Re: XML to either CSV or API call?

Post 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?
User avatar
magnussandstrom
Advanced member
Posts: 355
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: XML to either CSV or API call?

Post 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.
Last edited by magnussandstrom on Thu Feb 09, 2023 5:57 pm, edited 1 time in total.
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

Re: XML to either CSV or API call?

Post 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!!!!!
Post Reply