This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to save the content withen a table into a XML file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to save the content withen a table into a XML file?" Watch "How to save the content withen a table into a XML file?" New topic
Author

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

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 425
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.


To be or not to be. It's a question.
sasi kala
Ranch Hand

Joined: Dec 17, 2004
Posts: 68
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

Joined: Jan 28, 2005
Posts: 425
Yeah!
You do help me a lot.Now the problem is resolved.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to save the content withen a table into a XML file?
 
Similar Threads
Reading XML file from Server
what is wrong with this xml code
Need Dom Sample parser example
Using XSL to filter XML & Multiple XSLs
How to search a Vector array?