File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to save the content withen a table into a XML file?

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table like this:
-----------------------------
Name Sex
Superman M
Allen M
... ...
------------------------------
columName[] = {"Name", "Sex"};
data[] = {"Superman", "M", "Allen", "M", ...};
tableModel = New MyTableModel(columnName, data);

Now I want to press a "Save" button to save this to a XML file. How do I construct the file? I'm not familer with XML.
Thanks a lot.
your sincerely letter.
 
sasi kala
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i am sending sample code about how to write data to xml file. java to xml communication is possible with jdom.jar. first down load it and use this code to write data to xml file.

Needed changed...
1) This program will create "test.xml" in your "C Direcotry"
2) that file will contain one root element "Books" and several "Book"
sub tags.

<Books> <!-- this is root tag of xml file>
<Book>
<Title>AAAAAA1</Title>
<Author>asdf</Author>
<Cost>78</Cost>
</Book>
<Book>..........</Book>
<Book>..........</Book>
<Book>..........</Book>
</Books>
3)This code will write data to xml file to append data to xml file remove the commentsa and run the code.



Hope this helps u
All The Best
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah!
You do help me a lot.Now the problem is resolved.
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic