The best option is to create correct xml files that do not contain multiple line items and sequence numbers. Alternatively you calculate the maximum numeric and string values for each field. See attached qvw.
comm143934.qvw 168.0 K
Unfortunatly it not possible to create correct xml files because it s the output of a cashdrawer where multiple sequences means multiple sales.
Your calculation method takes a lot of time. I have to read over 65000 XML files. Is there an other option which takes less time?