I want to loop through my XML-file and if a text condition is true, do my thing. This is easy if i have one single place to look at, then I can do like this:
xmlget(‘/documents[1]/document[1]/commissions[1]/commission[1]/formid[1]’,Value,KeepCase,NoTrim)
But when i have several commission-tags within the commissions-tag, I don’t want to look at the first one found, I want to look at the current one like this:
xmlget(‘/documents[1]/document[current-one]/commissions[1]/commission[current-one]/formid[1]’,Value,KeepCase,NoTrim)
Is that possible to do? Is it built into PlanetPress Workflow in some way? Can I perhaps use a standard variable already defined?
I think we’ll need a little more information in order to help you.
What is your ultimate goal, here? Do you want to split the data and then use each chunk to create a document? Do you want to extract information from the data? Do you use metadata?
I will try to explain. I am creating content with the All in One Data mapping configuration, then I send the generated PDF-file to a folder with the “Send To Folder” action.
Depending on the text inside the current xml-tag named < formid > within the current tag < commission >, i want to name the file accordingly.
With help of xmlget(’/documents[1]/document[1]/commissions[1]/commission[1]/formid[1]’,Value,KeepCase,NoTrim) i can set a variable to the text inside the first < formid >-tag found.
To get the second i could write:
xmlget(’/documents[1]/document[1]/commissions[1]/commission[2]/formid[1]’,…)
The workflow loops through the complete xml-file, which can include many < commission >-tags. Each < commission >-tag generates a single PDF-file, and I want to name that file different, and it depends on the < formid >-tag within the current < commission >-tag.
I guess I can declare a variable named for example n, which increments with one everytime the loop begins, and then do:
I wanted to know if there already is something developed, like a standard variable, for this. I cannot be the first person who want to do some logic with a Text Condition check like this.
Well inside your loop, you natively have access to the %i variable, which contains the loop iteration value. The only problem in your case is that %i is 0-based, whereas the xmlget() function expects 1-based indexes.
So here’s what you can do:
Immediately after your Loop task, add a Mathematical Operations task with the following expressions: %i+1. Store the result in an ununsed JobInfo or in the variable or your choice (say, for instance, in %7).
Then, you can use xmlget(’/documents[1]/document[1]/commissions[1]/commission[%7]/formid[1]’,…)