Easiest way to create an XML document from a Data List

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #1

    Easiest way to create an XML document from a Data List

    I'm looking around the web to find a quick little library to make writing to XML quick, clean and painless.

    I'm getting confused by all the different options (JDOM, SAX, etc..)

    My question is, do you know of a class or library (as close as possible to native java libraries, e.g. no huge library import) that i could use with the below pseudo code?

    Code:
    // open document
    SomeLibrary X = new SomeLibrary('myNewfile.xml'); 
    X.addDTD('my.dtd'); 
    X.addRoot('my_root_element'); 
    
    forloop mydata {
       Eelment E = X.addElement('myElement'); 
       E.addAttribute('foo',myData[i].getFoo()); 
       E.addNode('child',myData[i].getChild());
    }
    
    // write and close
    X.write(); 
    X.close();
    Thanks for any suggestions and pointers. I'm looking into JDOM, but want to hear your advice first.

    Dan
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    I suggest you go with XML parser provided by JAVA under javax package.

    Regards
    Dheeraj Joshi

    Comment

    Working...