This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: txt -> xml


What is the format of your file?  If it is a simply delimited format, you
could easily create a shell script to split the original file into a simple
compliant XML file.  For example, to use VB-Script:

   Dim FSO
   Dim inputStream
   Dim outputStream
   Dim arrLine
   Dim i

   Set FSO = CreateObject("Scripting.FileSystemObject")
   Set inputStream = FSO.OpenTextFile("c:\temp\input.txt")
   Set outputStream = FSO.CreateTextFile("c:\temp\input.xml", True)

   outputStream.WriteLine "<?xml version=""1.0"" standalone=""yes""?>"
   outputStream.WriteLine "<input>"

   Do While inputStream.AtEndOfStream <> True
       arrLine = Split(inputStream.ReadLine, ",")
       
       outputStream.WriteLine "   <row>"
    
       For i = LBound(arrLine) to UBound(arrLine)
       	outputStream.WriteLine "      <col>" + Trim(arrLine(i)) + "</col>"
       Next
    
       outputStream.WriteLine "   </row>"
   Loop

   outputStream.WriteLine "</input>"

   outputStream.Close
   inputStream.Close

This will create an indented formatted XML file.  If you don't care about
readability, you can even use the Join function to cut some of this code
out.

	Steve

-----Original Message-----
From: Jakub.Valenta@Deio.net [mailto:Jakub.Valenta@Deio.net]
Sent: Monday, February 11, 2002 4:21 AM
To: XSL-List@lists.mulberrytech.com
Subject: [xsl] txt -> xml


Hi all,
I am currently looking for some nice tool which would allow to convert flat
file to xml. Does anyone know about some nice solution.
At the begining I would prefer some charge-free, but if there is non
commercial is good to. The best would be some tool which behave as an
SAX or DOM parser so I could use it to feed the XSLT engine, but it should
posses the capability to specify rules how the txt file should be
interpreted.

Does anyone know how the radix AnyToXML and AnyToAny works, any experiences
with it?

br,

Jakub


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]