wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to do XML databinding? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to do XML databinding?" Watch "How to do XML databinding?" New topic
Author

How to do XML databinding?

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
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

Joined: Dec 12, 2005
Posts: 3
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/).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to do XML databinding?
 
Similar Threads
convert javaobjects to xml and xml to java objects dynamically
Processing XML as "raw" Strings
Response xml-->XSLT -->output xml--> data binding
No message body reader found for request class in apache CXF
which way we can pass more than 25 parameters to a web service?