Hello,
I have never really worked with data in xml format and am trying to figure out how to parse it in OutSystems. I am querying a service that returns xml, and have included a copy of what the output looks like below. The output is very verbose, so I have removed a large portion of the output to make it easy to look at on the screen, but this is the main hierarchy of the output. Also, I have included only one entry, but the actual data will have multiple entries.
My goal is, for every entry, to extract field1, field2, and field3 and store them in a database entity. The datatypes for the 3 fields are int, string, and datetime. Would someone mind giving me a primer on how to do this?
Thanks!
<feed> <entry> <link title="MyTitle"> <m:inline> <entry> <content type="application/xml"> <m:properties> <d:Field_1 m:type="Edm.Int64">480063260</d:Field_1> </m:properties> </content> </entry> </m:inline> </link> <content type="application/xml"> <m:properties> <d:Field_2>20269469003</d:Field_2> <d:Field_3 m:type="Edm.DateTime">2020-09-25T00:01:00</d:Field_3> </m:properties> </content> </entry></feed>
Hi Ryan,
The easiest way to do this is by using a forge component like this:
https://www.outsystems.com/forge/component-overview/153/xml-records
Ossama
Thanks Ossama. I was wondering if someone had advice for how to do this without downloading forge components. We've experienced significant issues when upgrading versions of OutSystems, and I would like to avoid using tools that aren't officially supported by OutSystems if possible.
Ossama Ghanem wrote:
The forge component is nothing more than a code made by someone from community, so if you look how they made there you can use a similar approach to use in your own code if you don't want to use exactly how the component did.
I also experienced a similar predicament where I had to get data from an XML file to an entity. I took a shortcut and imported the data to an excel file first then bootstrapped the excel file to the entity.