Hi,
I have to parse complex XML files. I've been playing around for a while now but I'm stuck. The default XML tools in OutSystems don't seem to get me anywhere. Same goes for the XmlRecords component in the forge. Not sure, but I think it's because the XML contains nested elements.
The XML contains a list of products with product information. It looks something like this:
I'm able to read elements like <division> but that's it. Because it's a large XML file I would like to split the content and create a record per product in an entity so I can process them later and, if an error occurs, retry without having to process the complete XML again.
Can anyone shed some light on how to parse the XML? How can I get this XML into a record structure?
Thanks in advance.
Cheers,Ramon
Hello @Ramon Pigmans
The key to using the XML Records forge component, is to build the appropriate structure(s) for your xml. In the example you have provided, you will need the following structure:
I have attached the oml that uses the above structure.
Just click the Parse button to execute the demo. As an example I chose to parse the features and display it on the screen:
Best regards,
AJ
Hi Ramon,
You can convert xml to record list using below forge component
https://www.outsystems.com/forge/component-overview/153/xml-records
Thanks, Aadhavan S
Thanks for your answer @Aadhavan Shanmugam but if I'm not mistaken, XmlRecords does not support nested elements. Correct me if I'm wrong.
As the component's description states, it "allows you to convert an hierarchical structure", and it has a picture showing nexted structures. So I'd be surprised if what you think is true.
Yes. As Kilian Hekhuis mentioned, the component description itself mentioned the extension can able to convert a hierarchical structure.
Well, the description of the forge component states "Records composed of multiple structures are not supported". Also in the demo, the structure used has only one level. Guess I was thrown off by that and apparently I misinterpreted this.
Yeah, that's perhaps not very clear. What they mean is Records that have multiple Structures at the same level, like the output of Aggragates. For example:
Thanks a million @AJ. I've tried your solution and it works like a charm. I'll take this as the base for my solution and will develop it further. Thank you for your answer and taking the time to create a working example! This helps me a lot.