问题
I am getting NULL value eventhough there is some value in xml using jaxb unmarshalling.
Element in xsd
<xs:element name="Account" minOccurs="1" maxOccurs="unbounded" >
does not have type attribute.
In its respective Java class AccountNo become java.lang.Object type.
but after Unmarshalling xml
<AccountNo>GDF23232223</AccountNo>
output comes [AccountNo=NULL]
My unmarshalling code
jaxbContext = JAXBContext.newInstance("net.process");
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
document = (Document) jaxbUnmarshaller.unmarshal(inputFile);
can you help me?
Thanks
回答1:
I struggled with the same problem. Try to get the value using element.getFirstChild().getNodeValue()
There I got the correct value
来源:https://stackoverflow.com/questions/21211249/jaxb-unmarshalling-giving-null-to-anytype-element-in-xsd