I want to create an XML file from a text file
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Arun_V
Posted On:   Tuesday, March 25, 2003 11:07 PM

I have a .txt file which contains some atomic values separated by commas. From this .txt file I want to create an XML file of those values. How do I do this ? Can I get the code also ?

Re: I want to create an XML file from a text file

Posted By:   Roseanne_Zhang  
Posted On:   Wednesday, March 26, 2003 06:56 AM

You also can use Java, just read one line at a time. Then using a StringTokenizer to get one token at a time. Do the same thing Jan does in perl. Add a root, put each token into a child tag. It is simple and easy because your data is structured.

Re: I want to create an XML file from a text file

Posted By:   Roseanne_Zhang  
Posted On:   Wednesday, March 26, 2003 06:55 AM

You also can use Java, just read one line at a time. Then using a StringTokenizer to get one token at a time. Do the same thing Jan does in perl. Add a root, put each token into a child tag. It is simple and easy because your data is structured.

Re: I want to create an XML file from a text file

Posted By:   Roseanne_Zhang  
Posted On:   Wednesday, March 26, 2003 06:53 AM

You also can use Java, just read one line at a line. Then using a StringTokenizer to get one token at a time. Then do the same thing Jan does in perl. Add a root, put each token into a child tag. Simple and easy, it is because your data is structured.

Re: I want to create an XML file from a text file

Posted By:   Anonymous  
Posted On:   Wednesday, March 26, 2003 12:08 AM

Three possibilities:

  1. convert the file manually

  2. write a generator which will do the convertion once

  3. use an adapter


I did a quick hack in perl for the generator:

print "
";
foreach () {
chomp;
s/,/
/g;
print "
$_

";
}
print "
";

You can use that for starting. If you want write an adapter I recommend looking at chaperon (i never used it, but sounds good).
About | Sitemap | Contact