Upland OL User community

Repeat over NOT well-formed XML

I have some non-ideal XML that I have to try to make a dynamic table out of …


(Sorry image data does not match up)

My thought was to repeat on one of the elements (paymentDate), and try to grab the corresponding element (paymentAmount). I hoped I could access the current index of the repeat, but that doesn’t seem to be working.

… maybe If i create my own Index…??

Thanks for any help.

You could try to loop through the elements of PlanDetails.
Then inside the loop, extract each trio (paymentType, paymentDate, paymentAmount) via a script and populate the detailTable yourself.

It would be best to create the detail table PlanDetails in a previous Data Extraction before the loop with 3 empty fields already setup how you want them.

Then from within your script, populate it.

You’ll need to read this: PlanetPress Connect 2022.1 User Guide - table (objectiflune.com)

This can all be achieved easily with the proper XPATH selectors. You have to loop on all <paymentType> elements. When you extract the paymentType’s value, you simply use the “.” selector. Now in order to get the first following paymentAmount, you would use the “./following-sibling::paymentAmount” selector. For the paymentDate value, you’d use - you might have guessed by now - “./following-sibling::paymentDate”.

Obviously, this technique assumes the elements are ordered properly, exactly as if you had used an actual index.

Attached is a sample data mapping config that does just that: Siblings.OL-datamapper (3.4 KB)

Thank you both for the timely response!
hamelj - I did see reference to that method, but we are on 2020.1

Phil - Thanks for your XPath Experience. This was straightforward and worked beautifully.

1 Like