aspose file tools*
The moose likes XML and Related Technologies and the fly likes How to convert a text file into an xml? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to convert a text file into an xml?" Watch "How to convert a text file into an xml?" New topic
Author

How to convert a text file into an xml?

samir vasani
Ranch Hand

Joined: Nov 24, 2010
Posts: 59
Hi all,

Please guide for convertion of .txt to .xml
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Is it plain text or does it have some internal formatting?

What should the format of the XML be, and what is its purpose? This is important because there's an unlimited number of ways to convert an arbitrary text file into an XML file.
samir vasani
Ranch Hand

Joined: Nov 24, 2010
Posts: 59
Lester Burnham wrote:Is it plain text or does it have some internal formatting?

What should the format of the XML be, and what is its purpose? This is important because there's an unlimited number of ways to convert an arbitrary text file into an XML file.



The formate of my .txt is:

invoice_number product_number product_description
12321212 45612 abcdasksalaknsdlandaks
67812121 78921 xyzasdjcakbjasbckasccbc
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
OK. Various classes in the java.io package and the use of some methods in the String class should be sufficient to handle that.
samir vasani
Ranch Hand

Joined: Nov 24, 2010
Posts: 59
Lester Burnham wrote:OK. Various classes in the java.io package and the use of some methods in the String class should be sufficient to handle that.


I am having the text file in the following formate.

Java|http://www.rgagnon/javahowto.htm
PowerBuilder|http://www.rgagnon/pbhowto.htm
Javascript|http://www.rgagnon/jshowto.htm
VBScript|http://www.rgagnon/vbshowto.htm

And the code for the above file is



This works perfect for the above given .txt file

But the on which i wish to work is in the following formate:
I have attached the file,becuase the view of the .txt is imperfect.
So please find the attached copy and go through it

So i to change the code for the above formate
Help me please to resolve it

[ UD: In the future, please UseCodeTags when posting code of an length. It's unnecessarily hard to read the code ptherwise, making it less likely that people will bother to do so. ]
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
You need to look at JAXB or Castor for this.


-Varun -
(My Blog) - Online Certifications - Webner Solutions
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
I have attached the file,becuase the view of the .txt is imperfect.

I don't see that; try posting it.

You need to look at JAXB or Castor for this.

No. There are any number of ways of creating XML, including the one shown in samir's code. What's more, tools like JAXB and Castor suppose the existence of Java classes that are mapped to XML elements - yet samir's posts don't sound like those classes exist.
samir vasani
Ranch Hand

Joined: Nov 24, 2010
Posts: 59
Lester Burnham wrote:
I have attached the file,becuase the view of the .txt is imperfect.

I don't see that; try posting it.

You need to look at JAXB or Castor for this.

No. There are any number of ways of creating XML, including the one shown in samir's code. What's more, tools like JAXB and Castor suppose the existence of Java classes that are mapped to XML elements - yet samir's posts don't sound like those classes exist.



I want guidence or code for the following text formate

invoice_number product_number product_description
B4763020 64012 GAMIMUNE N 5% 10ML
12345555 32323 abcdswbfjwbcbwjcb
12345123 12323 abaswbfjwbcbwjcb
54545555 32223 zxcdswbfjwbcbwjcb
14545555 44323 abcdswbfjwbcbwjcb


please notuce one thing that there is a tab space("/t") between each column
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
This:

doesn't look substantially different from this:

Different delimiter character, and different number of items per line, but that's about it. What problems are you encountering while adapting your earlier code?
samir vasani
Ranch Hand

Joined: Nov 24, 2010
Posts: 59
Lester Burnham wrote:This:

I want out put of xml in the following formate

Different delimiter character, and different number of items per line, but that's about it. What problems are you encountering while adapting your earlier code?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
What do you have so far? What does it do, and where are you stuck making it do what you want it to do?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to convert a text file into an xml?
 
Similar Threads
making XML Doc from JDBC Results
iText problem with html-table to pdf
Pronounciation of "Buzz Words"
Ajax Jqery xml response - not able to read response
Castor Mapping