I am struggling with some JAXB parsing and need guidance.
Essentially, I'm trying to add attributes to my class variables, which I have already declared as Elements using @XmlElement. So far, any attempt to use @XmlAttribute has set the attribute at the class level.
I am currently getting the following:
<DataClass newAttribute="test"> <myElement>I wish this element had an attribute</myElement> <anotherElement>I wish this element had an attribute too</anotherElement> </DataClass>
I would like to do this:
<DataClass> <myElement thisAtt="this is what I'm talking about">This is better</myElement> <anotherElement thisAtt="a different attribute here">So is this</anotherElement> </DataClass>
I saw that other posts add an attribute to a single element using @XmlValue, but this does not work when you have elements, and will not work with multiple elements.
Does anyone have a thought on how to do this?
Thanks! Jason
source share