By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,737 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,737 IT Pros & Developers. It's quick & easy.

How to convert a text data into xml data?

P: 61
Hai to all...
this is senthil....

i want to convert a text data into a xml data....

is there any source codes available in the net?

or is there any methods, classes available for this type of conversion?

Can any one plzz tell me?

thanks
senthil.
Dec 27 '06 #1
Share this Question
Share on Google+
11 Replies


P: 61
Hai any one plzz explain me about this...

i will explain u clearly what i have to do....

Expand|Select|Wrap|Line Numbers
  1. i'm having XML codings for creating a table in a mysql database...
  2.  
  3. these xml codings are written into a single field in a database...
  4.  
  5. what i have to do is...
  6.  
  7. i have to write these xml codings into a file in which the file
  8. to be saved as xml file...
Can any one plzz explain me
Dec 28 '06 #2

10K+
P: 13,264
Hai any one plzz explain me about this...

i will explain u clearly what i have to do....

Expand|Select|Wrap|Line Numbers
  1. i'm having XML codings for creating a table in a mysql database...
  2.  
  3. these xml codings are written into a single field in a database...
  4.  
  5. what i have to do is...
  6.  
  7. i have to write these xml codings into a file in which the file
  8. to be saved as xml file...
Can any one plzz explain me
Well you asked for available codes which I do not have. I'm not very good at XML so the only way I can solve your problem is to "manually" create the XML
using FileWriter class. How to do this would depend on the structure of data in the text file and the structure required for the XML file. If that is not good enough for you then maybe someone else who knows a conventional method of creating the XML file will be able to help you.
Dec 28 '06 #3

P: 61
Hai r035198x,

thanks for ur reply....

i will explain u till clearly what i have to do...

plzz give me some more hints after that

Expand|Select|Wrap|Line Numbers
  1. i'm having XML codings for creating a table in a mysql database...
  2.  
  3. these xml codings are written into a single field in a database...
  4.  
  5. what i have to do is...
  6.  
  7. i have to retrive these xml codings into a file in which the file
  8. to be saved as xml file... 
  9.  
  10. retriving is not a problem to me...
  11.  
  12. But i have to save that retrived xml codings into a xml file...
plzz give me some more hints..

thanks..
senthil..
Dec 28 '06 #4

10K+
P: 13,264
Hai r035198x,

thanks for ur reply....

i will explain u till clearly what i have to do...

plzz give me some more hints after that

Expand|Select|Wrap|Line Numbers
  1. i'm having XML codings for creating a table in a mysql database...
  2.  
  3. these xml codings are written into a single field in a database...
  4.  
  5. what i have to do is...
  6.  
  7. i have to retrive these xml codings into a file in which the file
  8. to be saved as xml file... 
  9.  
  10. retriving is not a problem to me...
  11.  
  12. But i have to save that retrived xml codings into a xml file...
plzz give me some more hints..

thanks..
senthil..
Are these XML codings strings that you have to convert to XML tags?
If so what is the structure of the strings(What tells you when a tag should be started and ended)?
Dec 28 '06 #5

P: 61
No no...

in the database....

there is xml codings for creating a table with xml tags which is now just like
the followilng
<xml>
<codings for creating a table>
</xml>

Only i have to retrive these codings(just like retriving an information)
from the database and i have to write these codings into a file in which
the file to be saved as xml file...

can u get any idea...

thanks
senthil
Dec 28 '06 #6

10K+
P: 13,264
No no...

in the database....

there is xml codings for creating a table with xml tags which is now just like
the followilng
<xml>
<codings for creating a table>
</xml>

Only i have to retrive these codings(just like retriving an information)
from the database and i have to write these codings into a file in which
the file to be saved as xml file...

can u get any idea...

thanks
senthil
I get the picture. I still don't think I'm the best person to help you on this but

You said you can retrieve these codings. How are you retrieving them? As strings or some other data type?
Dec 28 '06 #7

P: 61
Only i can retrive them as strings...
Dec 28 '06 #8

10K+
P: 13,264
Only i can retrive them as strings...
if you can retrieve as strings then maybe this might help. It creates the file from an array of strings

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. public class WriteFile {
  3.          public static void main(String[] args) {
  4.     try {
  5.         File file = new File("test.xml");
  6.         BufferedWriter out = new BufferedWriter(new FileWriter(file));
  7.         String[] ss = {"<XML>", "<Test>", "</TEST>", "</XML>"};
  8.         for(int i = 0;i < ss.length; i++) {
  9.             out.write(ss[i]);
  10.             out.newLine();
  11.             out.flush();
  12.         }
  13.     }
  14.     catch(IOException io) {
  15.         io.printStackTrace();
  16.     }
  17.     }
  18. }
Dec 28 '06 #9

P: 61
Hai,

very very thanks for ur support and guidance....

i want to do some modifications in ur program,

bcoz i have to retrive that string from database...

i will try it and tell to u what the result is.

thanks...
senthil
Dec 28 '06 #10

10K+
P: 13,264
Hai,

very very thanks for ur support and guidance....

i want to do some modifications in ur program,

bcoz i have to retrive that string from database...

i will try it and tell to u what the result is.

thanks...
senthil
Welcome. Instead of the array and for loop you now sbstitute that with the values coming from the database.
Dec 28 '06 #11

P: 61
Hai r035198x
ur conditions worked supervly
when i used for writing a string into a file...

But when i tried to writed the string which is fetched from the database
it is not working....

But anyway i will do the second step surely....

basically i'm working in the field of VC++....

But ur codings gave me an idea to write a file...

Hereafter i will do my work well...

thanks for ur support
senthil
Dec 29 '06 #12

Post your reply

Sign in to post your reply or Sign up for a free account.