BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


SQL XML
XML IMDB Concepts.
Using XML as a Data Store
Creating An XML Based Cache Using COM
Character encoding, a few words on the subject
How to use the ADO Stream object to retrieve SQL2000 XML
How to transfer XML into a plain text file?
Convert XDR to XML
Sort a table using the header of the table
Applying a XSLT stylesheet using the DBMS_XMLQuery package
N:N relationships with DBMS_XMLQuery Package
DBMS_XMLQuery package bind values to produce more than one xml file
Download data from a database in XML
Inserting XML file into a table using DBMS_XMLSave Package
Insert XML file into a table using ADO
How to call out to a COM component's method through XSLT
How to select DISTINCT items from XML via XSLT
How to convert Word (RTF) documents to XML for auto publication
Creating SQL Statements with XSLT
SQL straight to XML w/ transform
History Of XML


 
 

<< SEOSystem.XML >>


By Pedro Gil
First Posted 07/05/2001
Times viewed 343

Convert a flat text file into xml


This post contains attachments
v20010705195310.zip 

Summary Use ADO and the Text ISAM to persit im XML a flat text file

I don't known if you like me still have to deal with a lot of flat files, almost every system at my office still send and receive data in that way.

My question was how can we transform a flat text file in xml, I known how we can use XSLT to transform XML in a text file, reading on Michael Kay book it's mentioned that you can build your own parser to be able to transform a any source file, including a flat text file. But this is not a task a newbie want to delve in I'm sure.

So I made this simple snippet, I think that simple solutions are great :-)

I've made this code using Access 97, but you can with some easy stuff pass it to VB or Access 2000, I'm also using ADO2.6 and Jet4 sp3.

What I'm doing? I taking advantage of ADO ability to connect to any source, you can build your own OLE DB to access any source, but then again, we fall on the parser problem, but Jet already has a Text ISAM driver. I'm used to use it in Access and DAO, but it's also available in ADO. When you use it on Access you must build a import schema, that is kept in the MSysIMEXSpecs and MSysIMEXColumns tables, but you can also use a external file Schema.ini, that is the thing we need.

So I've build up a schema.ini file, open a recordset based on the flat text file and the schema.ini, and just persist it to XML. We have converted it to XML, it use the XDR schema of ADO, but here you can use XSLT to transform this into anything you want.

The schema.ini file must be in the same directory as the text file.

Remember this is my first attempt, so just small stones please… also sorry for the bad English.

BTW - I've made some test with a somehow large file, and it's as a fast operation, I was thinking that this could be somehow a resource drain, but then I've to make more test, if you find something that you want to share with me please do so.

Additional information


Rate this article on a scale of 1 to 10 (0 votes, average 0)

Your vote :  

<< SEOSystem.XML >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML