Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Text to XML

Status
Not open for further replies.

ceh4702

Programmer
Jul 25, 2001
2,065
US
I want to convert an ASCII plain text file with fixed width fields to XML.

File source:

COBOL TEXT Mainframe ALL Caps Fixed Length saved as Notepad on my PC.

Is there some kind of easy program to do this?

Have you got some links?

If I want to preserve all Spaces can I do that? Some fields have spaces and some have spaces on the end. Is it possible to pad the spaces instead of chopping them off like a database file would do?

Not a big fan of CSV.



If you do not like my post feel free to point out your opinion or my errors.
 
Tools exist. Try StylusStudio. I have been using it the last few days. It has an Import CSV to XML wizard, though that is not the functionality I have used.

Certainly XML understands spaces and will preserve them if you wish.

You might also want to have a look at Liant's XML Extensions.

Tom Morrison
 
This would be pretty easy to do with XSLT. Use a text editor (if on UNIX, use sed so you can create a reusable script) to wrap each line with a tag, then wrap the whole document in a root tag. Now that you have an XML document, you can use XSLT's substring functions to chop up each input line as needed.
 
Thanks for the Ideas.

I actually downloaded the StylusStudio program to preview it. I think the technical assistance staff for our program we use for sending the files is going to come up with a solution for now.

I like the idea of the script. I could probably write a simple COBOL Program that can do just about all that or part of it. COBOL is just basically a text processor. I looked at XML and it looks similar to HTML in design. I will play around with it and see what I think.



If you do not like my post feel free to point out your opinion or my errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top