Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to do XML databinding?

 
Siegfried Heintze
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to read in a short XML file to populate the drop downs in a dialog box. After the user has made his selections, I need to alter the contents of a second larger (200 lines) xml file.

How would you do this? I was thinking I would use databinding. What is fashionable these days? I have Brett's book "Java, XML & Databinding" and it discusses Zues and mentions JAXB but the book is kinda old (may 2002). Are there more fashionable ways to load an XML file into a plain old java object?

How would you do it? Would you bother with databinding? I could just use xerces, I suppose. Ugggh...
Thanks,
Siegfried
 
Craig Caulfield
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data binding is a good option if you don't want to get down to the nitty gritty of DOM and SAX programming.

Brett McLaughlin's book was one of the first to discuss data binding and suffers because it came out when the technology was still evolving. Check out IBM developerWorks (http://www-128.ibm.com/developerworks) for a good range of up-to-date articles and tutorials on data binding.

My personal favourite is JAXB: it's simple and powerful and if you're working with web services you'll probably come across it anyway. Currently JAXB it is part of Sun Web Services Developer Kit, but it will soon become part of the standard JDK.

An alternative worth trying if you're looking for a lightweight solution for reading, say, configuration files, is the Apache Jakarta Commons Digester (http://jakarta.apache.org/commons/digester/).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic