• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

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

 
Ranch Hand
Posts: 434
  • 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.
 
Ranch Hand
Posts: 68
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah!
You do help me a lot.Now the problem is resolved.
Thanks.
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic