title: Simple XML deserialization
body: <p>I am trying out the <a href="http://simple.sourceforge.net/home.php" rel="noreferrer">Simple XML serializer</a>. I am more interested in deserialization from XML->Java. Here is my code as a unit test:</p>
  
  <pre><code>import java.io.StringReader;
  import java.io.StringWriter;
  
  import junit.framework.TestCase;
  
  import org.simpleframework.xml.Attribute;
  import org.simpleframework.xml.Root;
  import org.simpleframework.xml.Serializer;
  import org.simpleframework.xml.core.Persister;
  
  public class SimpleTest extends TestCase {
      public void testWriting() throws Exception {
          StringWriter writer = new StringWriter();
          Address address = new Address("1234 Main Street", "San Francisco", "CA");
          Serializer serializer = new Persister();
  
          serializer.write(address, writer);
          System.out.println("Wrote: " + writer.getBuffer());
      }
  
      public void testReading() throws Exception {
          String input = "&lt;address street='1234 Main Street' city='San Francisco' state='CA'/&gt;";
          Serializer serializer = new Persister();
          System.out.println("Read back: " + serializer.read(Address.class, new StringReader(input)));
      }
  }
  
  @Root
  class Address {
      @Attribute(name="street")
      private final String street;
  
      @Attribute(name="city")
      private final String city;
  
      @Attribute(name="state")
      private final String state;
  
      public Address(@Attribute(name="street") String street, @Attribute(name="city") String city, @Attribute(name="state") String state) {
          super();
          this.street = street;
          this.city = city;
          this.state = state;
      }
  
      @Override
      public String toString() {
          return "Address [city=" + city + ", state=" + state + ", street=" + street + "]";
      }   
  }
  </code></pre>
  
  <p>This works, but the repeated <code>@Attribute</code> annotations (at the field and at the constructor argument) in the Address class look ugly. Is there some way to:</p>
  
  <ul>
  <li>have simple figure out the attribute name from the field name?</li>
  <li>have simple ignore serialization, so that I can get away with annotating either the fields or the constructor argument?</li>
  </ul>