title: Adding an Attribute to a JAXB Element
body: <p>I'm struggling with some JAXB parsing and need some guidance.</p>
  
  <p>Essentially, I'm trying to add attributes to my class variables that I have already declared as Elements using @XmlElement.  So far, any attempt to use @XmlAttribute sets the attribute at the class level.</p>
  
  <p>What I"m currently getting is this:</p>
  
  <pre><code>&lt;DataClass newAttribute="test"&gt;
    &lt;myElement&gt;I wish this element had an attribute&lt;/myElement&gt;
    &lt;anotherElement&gt;I wish this element had an attribute too&lt;/anotherElement&gt;
  &lt;/DataClass&gt;
  </code></pre>
  
  <p>I'd like to to do this:</p>
  
  <pre><code>&lt;DataClass&gt;
    &lt;myElement thisAtt="this is what I'm talking about"&gt;This is better&lt;/myElement&gt;
    &lt;anotherElement thisAtt="a different attribute here"&gt;So is this&lt;/anotherElement&gt;
  &lt;/DataClass&gt;
  </code></pre>
  
  <p>I've seen other posts add an attribute to a single element using the @XmlValue, but that doesn't work when you have Elements, and won't work on multiple elements.  </p>
  
  <p>Does anyone have a thought on how this could be accomplished?</p>
  
  <p>Thanks!
  Jason</p>