title: Serializing multiple tiers of XML elements
body: <p>Let's say I'm trying to create an XML document out of an object. Is this possible using JAXB annotations on a single Food class, or do I need to create inner classes for Cost and Flavor?</p>
  
  <p>I know I can use @XmlElement or @XmlAttribute to set up immediate children of my root element. However, I'm not sure if/how to create the <code>&lt;cost&gt;</code> and <code>&lt;Flavor&gt;</code> tags as I show here.</p>
  
  <pre><code>&lt;Food&gt;
    &lt;cost amt=13.5 unit=USD/&gt;
    &lt;Flavor spicy=5&gt;It tastes good&lt;/Flavor&gt;
  &lt;/Food&gt;
  
  
  @XmlRootElement("Food")
  public class Food {
  
     private float amount;
     private String units;
     private String flavorType;
     private STring flavorDescription;
  }
  </code></pre>