2 Replies Latest reply on Aug 19, 2012 4:31 AM by prasaxen

    Convert Text file to XML?


      Hi there, I have a newbie question that I am hoping someone can help me with.

      I have to create a process in ES2 that leverages a watched folder as the end point.  The incoming data file is TXT file that has the data formatted like the following:







      The process needs to first save the data to a seperate DB table outside of LC and then send an email notification to the contact name.  There is no PDF form or User Tasks required in these operations. 


      My initial question is what to do with the format of the incoming data file.  I am assuming it should be first converted to XML before the LC process consumes it.  What would be the best approach to go about doing this? 


      Many thanks



        • 1. Re: Convert Text file to XML?
          $Nith$ Level 4

          Use Properties class to read values from the file and then create an XML document using DOM Parser.


          After conversion, you can send the XML through email.



          • 2. Re: Convert Text file to XML?

            Best approach would be to make the input file of xml extension and provide values in different xml tags ,so your input would look as:-







            In your ES2 process, make one input variable of type document for taking this xml file. Now once this document (xml) type file comes in ur process. then use SetValue component to convert the content type of this document to "application/xml".


            e.g. Input variable name is "inXMLDoc" of type document which would be consuming xml file from watched folder. Also make one more process variable "inXML" of type xml. Now in SetValue , in location type "/process_data/@inXML" and in expression type "setContentType("/process_data/@inXMLDoc","application/xml")".


            So through this you can get your xml file in xml variable named inXML and retrieve content of it using XPath.


            Let me know if it resolves ur problem.