Skip to main content

JAXB how to get element name

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-03-27


I am trying to get the element name for a JAXB class.


Then if class is SomeElement then what i plan to do is:

getElement(ObjOfSomeElement) --> someelement

I tried the JAXBInstrospector but that requires the classes to have @XMLRootElement.

My generated clases do not have this and i was reading your post for

Why does JAXB put @XmlRootElement sometimes but not always?


I tried that but still the XMLRoot element does not get generated.

I am using JDK 1.7. IS your post still valid and also if there any trial way to get the element name.