jaxb unmarshalling giving NULL to anytype element in xsd

一曲冷凌霜 提交于 2020-01-02 10:23:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!