I am having an issue unmarshalling with JAXB for an XML file. There is an attribute on some of the xml elements called "display_value" which I need to obtain. Here is a small example of the XML file:
<unload>
<change_request>
<active>true</active>
<approval>not requested</approval>
<assigned_to display_value=""/>
<alt_poc display_value="Tom Ford">056468745677484657</alt_poc>
<poc display_value="Matt Ryan">56465148754878</poc>
</change_request>
</unload>
I assume that in my ChangeRequest class I would simply annotate @XmlAttribute(name="display_value) on the fields that have the display_value that attribute, such as alt_poc but that doesn't seem to work. Here is an example of my ChangeRequest class.
@XmlAccessorType(XmlAccessType.FIELD)
public class ChangeRequest{
String active;
String approval;
String assigned_to;
String alt_poc;
String poc;
}
I do have a class that contains a list of ChangeRequest objects, called ChangeRequests. This class is simple and looks like:
@XmlRootElement(name="unload")
public class ChangeRequests{
ArrayList<ChangeRequest> changeRequestList;
@XmlElement(name="change_request")
public ArrayList<ChangeRequest> getRecords(){
return changeRequestList;
}
Finally I will show you the JAXB code where I do all of this
URL url = new URL("wwww.somethingInteresting.com/syz.xml");
try {
JAXBConext jc = JAXBContext.newInstance(ChangeRequest.class, ChangeRequests.class);
Unmarshaller un = jc.createUnmarshaller();
return (ChangeRequests) un.unmarshal(url);
} catch(JAXBException e){
thow new RunTimeException(e);
}
Currently, all the code works, however I cannot get the display_value when I need it. Instead of the display_value I am getting the long number like 65484435487.
Any help anyone can provide would be great. Thank you!