16
Views
3
Comments
Parse XML to a database entity
Question

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>

Rank: #353

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

Rank: #222

Hi Ryan,

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.