2 Replies Latest reply on Aug 10, 2010 7:15 AM by adobeMurat

    Extract and save xml nodes to filesystem

    tgsoft Level 1

      Hi All,


      I am looking for great ideas for the best way to extract xml nodes from a complete xml-file and save each to a given path in the filesystem, with filename incremented for each file... file1,2,3,4.


      I have a process in workbench that takes an xml file as input (complete XML shown below). In the complete solution I will have an unknown number of child nodes to save.


      Complete XML file with two records. Is in a process variable "xmlComplete" - type=xml:




      Want to save each child record (<indexRec>) to the filesystem. Lets say to C:\temp\records\file1.xml   (..2.xml etc) and with content like this.




      What kind of solution would you advice?? An execute script with loop or a loop of setValue steps??

      Hope for great input. feel free to ask for more info if needed, Thanks



      Thomas Groenbaek

        • 1. Re: Extract and save xml nodes to filesystem
          $Nith$ Level 4

          Your requirement is much easy to implement with simple activities such as SetValue, WriteXML etc.


          I prefer not to use Execute Script activity for this simple logic.



          • 2. Re: Extract and save xml nodes to filesystem
            adobeMurat Level 1


            You need to create a loop in your process on workbench. First count nodes and set it to an integer variable.


            /process_data/@number = count(/process_data/xmlComplete/archiveIndexRecords/indexRec)


            Then you need to get first node's data to write to disk.


            /process_data/FirstNode = /process_data/xmlComplete/archiveIndexRecords/indexRec[number(/process_data/@i)] (i is another integer variable which is 1 as default. )


            When you get first node's data set it to a document variable and write down to disk. Then add 1 to i variable and control it with number (count of nodes) variable. Decide for next record or not.


            You can find an example how to create loops in workbench link below.