How do I get the object from JAXBElement<Object>

java, xml

Solution

You need to use the `getValue()` method.

 JAXBElement<ArrayOfLeadRecord> r = l.getLeadRecordList() ;
 List<LeadRecordList> leadRecordList = r.getValue().getLeadRecordList();

Problem

I have : ``` JAXBElement<ArrayOfLeadRecord> r = l.getLeadRecordList() ; ``` How can I get the actual `ArrayOfLeadRecord` as an object? It took me so long to unmarshal/convert this `JAXBElement` to the actual object I want. Thanks a lot....

Original source