10-13-2022 22:22 PM
Directly using the Insert XML element action inserts only to the first node mentioned in the XPath query.
Use an XPATH on the book node.
Since there are 4 books, the count property of the Output variable ie; %XPathResults.Count% will have a count of 4 in this example.
Note: There is a XPATH function called as Count() that is normally used to find out the count of nodes.
But this function did not seem to work in the above action. Perhaps, functions are not yet supported.
Lets call it NodeCounter.
Remember to increment it.
Example: /bookstore/book[1] selects the first book element that is the child of the bookstore element
Since this is within a loop, the counter will be applied to all the book nodes of the XmlDocument
Finally, using Write XML to file action use this variable to generate your final Xml file. (Reference video for writing to file here)