Data mapper test for tag before mapping

hi there

I have an xml file mapped but some records do not have the node im using to create a detail table, so the goto fails, how do i test if the node exists before trying to go to it?

Hi Richard,
Probably the simplest way is to put the detail table repeat in a condition. In the below example I put it in a condition to test if the node containing the field for the table is empty or not:

I hope this helps.

Best Regards

Justin Leigh

thanks Justin, we were playing with ideas and this is what we thought BUT its a node that contains others ie

so the above would be 3 “invoice” inside the “invoices” node

my problem is when there are no “invoice” they havent included the “invoices” node so I need to test if the “invoices” node exists not if its empty or not…

or have i read this wrong ans thats what it will do ? (sorry im a little new to xml)

Hi Richard,
In the attached example, the node is missing from the second record and therefore is ignored.

Best Regards

Justin
xml_forum.OL-template (9.3 KB) xmlmulti.OL-datamapper (4.6 KB)

Thanks so much Justin, i couldn’t open the examples you posted but i think this is where i went wrong… using the node as the xpath reference will always be empty, exists or not, where as using a tag name in the node, this holds a value so returns T or F, see below, I am using a number in the reference but i dont think its needed?

Thanks again mate

Richard,

Your best bet is to use the count() function to check if the number of target elements is greater than 0:

image

Note also that I have redacted your original image. Please always make sure to anonymize your data before posting a screenshot and to specify that the data has indeed been anonymized.

Thanks Phil, that’s a better solution than checking for empty… thanks also for blanking out the details, sorry I didn’t give that a thought …

thanks for your help guys, much appreciated

best regards, Richard