title: How do I convert XML into a java value object?
body: <p>What kind of open-source libraries are available to convert XML into a java value object? </p>
  
  <p>In .Net, there is a way to easily do this with xml serialization and attributes. I would imagine there some parallel in java. I know how to do this with a DOM or SAX parser, but I was wondering if there was an easier way.</p>
  
  <p>I have a predefined XML format that looks something like this.</p>
  
  <pre><code>&lt;FOOBAR_DATA&gt;
    &lt;ID&gt;12345&lt;/ID&gt;
    &lt;MESSAGE&gt;Hello World!&lt;/MESSAGE&gt;
    &lt;DATE&gt;22/04/2009&lt;/DATE&gt;
    &lt;NAME&gt;Fred&lt;/NAME&gt;
  &lt;/FOOBAR_DATA&gt;
  </code></pre>
  
  <p>In .Net, I can do something like this to bind my object to the data.</p>
  
  <pre><code>using System;
  using System.Xml.Serialization;
  
      namespace FooBarData.Serialization
      {
        [XmlRoot("FOOBAR_DATA")]
        public class FooBarData
    {
      private int _ID = 0;
      [XmlElement("ID")]
      public int ID
      {
        get { return this._ID; }
        set { this._ID = value; }
      }
  
      private string _Message = "";
      [XmlElement("MESSAGE")]
      public string Message
      {
        get { return this._Message; }
        set { this._Message = value; }
      }
  
      private string _Name = "";
      [XmlElement("NAME")]
      public string Name
      {
        get { return this._Name; }
        set { this._Name = value; }
      }
  
      private Date _Date;
      [XmlElement("DATE")]
      public Date Date
      {
        get { return this._Date; }
        set { this._Date= value; }
      }
  
      public FooBarData()
      {
      }
    }
  }
  </code></pre>
  
  <p>I was wondering if there was a method using annotations, similar to .Net or perhaps Hibernate, that will allow me to bind my value object to the predefined-XML.</p>