0

I have an application where I have different checkboxes placed in JTable. I want to get the selected values of the column to create an xml file based on the value selected by user.

There are different attributes in it and I want to select selected data using check box. Whenever I click on save button there should be one dialog box asking me where to save the file after entering the path it should get saved to.

The XML file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<data>
<Tab name="text123">
    <Test name="abcd">
        <affected url>http://www.a.com</url>
        <field-1 param="abc">value=text</field-1>
        <filed-2 param="xyz">value=text</field-2>
    </test>
    <test name="xyz">
        <affected url>http://www.b.com</url> 
        <field-1 param="mno">text</field-1>
        <filed-2 param="pqr">text</field-2>
    </test>
</tab>
</data>

The data I'm getting in my custom tab is dynamic and params and their value are getting stored in JTable whenever check box are placed.

Franz Kafka
  • 10,623
  • 20
  • 93
  • 149

1 Answers1

0

do you have to keep some structure of your xml file or is it completely up to you? To transform any object into XML string you can use XmlDecoder and XmlEncoder, which are both in rt.jar. To save it into XML file you can use JFileChooser or any custom dialog of your design. I do not remember exactly the code, but you can set supported suffixes to native JFileChooser as well.

Jan Hruby
  • 1,477
  • 1
  • 13
  • 26
  • i have to keep structure similar like this...yes JFileChooser i can use for the save dialog box and can set its default property but then also i want this structure..any sample code regarding that ?? – nishita wadhawan Apr 10 '13 at 14:00
  • Anyone...please help me with that...:(( m still stuck with my code – nishita wadhawan Apr 11 '13 at 17:12