What my grand goal would be is to check which files exist from <orderedSizes>, remove those from the main xml and then send only the missing ones to printing. For this i would need to merge the xml again after eliminating the existing sizes from <orderedSizes>.
I am sure it is not, but this sounds very strange to me. First of all, how can S or L be a file? It must be a combination of different pieces from the XML that makes up a path to a file that could exist. What baffles me completely is that you want to print the missing files. How can you print a missing file?
My last move would be to re combine the files to a single xml again so that orderedSizes would be together like in the beginning
You do not mention it explicitly but based on what you wrote in the first quote I assume you only want the missing "files" to remain in the XML. Is this really necessary? Is it not enough to continue working with the individual files?
Anyhow, I would script it, but here is an attempt to describe a solution that does not require a script:
- chain the Scan hierarchy app as many times as the maximum number of orderedSize nodes. In the variable for the filename use the XPath that ends in orderedSize[1] for the first instance, orderedSize[2] for the second, etc.
- when the file is found place that XPath in a piece of private data and call it e.g. orderedSize1, orderedSize2, etc., when the file is not found do not do anything
- at the end you use the XML Magic app to remove the unwanted nodes. There will be as many lines as the maximum number of orderedSize nodes and on each line you use one of the private data key as the XPath. When the node has to be removed private data key orderedSize3 for example will contain a valid XPath and it will get removed and when the private data is empty because it does not exist I assume XML Magic will do nothing (to be tested!).
IMPORTANT: the removal of the nodes has to be done in reverse order! Otherwise the order gets mixed up: when you remove orderedSize[2] then orderedSize[5] becomes [4] and if you then remove [5] you are removing the [6] from the original.