72
Views
3
Comments
Solved
[XML Records] Unable to read multiple children in XML element
xml-records
Service icon
Forge asset by Afonso Carvalho
Application Type
Service
Service Studio Version
11.53.13 (Build 61176)
Platform Version
11.14.1.34396


Hi. I have 30 or 40 xml tables I must read from a supplier. I can read most of them. But several of them have some repeated child elements which I can't seem to read.

e.g. in below the <RestaurantAreas> has multiple child <RestaurantAreaCodeId> elements, and I only seem to be able to read the first in the list. Can anyone please help me? 

I have attached my test (TestXmlRecords.oml) that I'm using.


TestXmlRecords.oml
2019-06-15 21-39-22
Afonso Carvalho
 
MVP
Solution

Hello Alan,

You're only receiving the first value of the XML element list because in the Structure, RestaurantAreaCodeId is defined as a Text value and not as an actual List.

I've attached an .oml of a Structure that is able to contain your XML example - note how the Brands and RestaurantAreas Structures are defined, it's the same idea in both cases. It's not outputting to the Screen, but you should be able to confirm the results while debugging the Preparation of WebScreen1:


Let me know if you need any further assistance.

XMLSameName.oml
2017-04-10 03-24-23
Alan Telford(Maxtel)

Thank you for your response, and the working example.

I had tried 3 different options, including the one you gave, but they weren't working for me. 

In my working solution I had several files all with the BRAND group inside, and so I had renamed them Brand1, Brand2, Brand3, and this must have been preventing the read.

I had to copy the data structures to a separate module (so there were no name clashes) with the other XML files I was reading, and then it started working correctly. 

An interesting lesson to learn when you have lots of XML files to read!

Thanks again.

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

The translation from XML to Structures is a little awkward, especially when you have more complex documents to process.

Glad to hear you got it working, good luck.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.