jaxb解组xsd中的anytype元素为NULL [英] jaxb unmarshalling giving NULL to anytype element in xsd

查看:46
本文介绍了jaxb解组xsd中的anytype元素为NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管使用jaxb编组的xml中有一些值,但我还是得到了NULL值.

I am getting NULL value eventhough there is some value in xml using jaxb unmarshalling.

xsd中的元素

<xs:element name="Account" minOccurs="1" maxOccurs="unbounded" >

没有类型属性.

在其各自的Java类AccountNo中成为java.lang.Object类型.

In its respective Java class AccountNo become java.lang.Object type.

但在将XML解组后

<AccountNo>GDF23232223</AccountNo>

输出为[AccountNo = NULL]

output comes [AccountNo=NULL]

我的解组代码

 jaxbContext = JAXBContext.newInstance("net.process");
   Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
   document = (Document) jaxbUnmarshaller.unmarshal(inputFile);

你能帮我吗?

谢谢

推荐答案

我也遇到了同样的问题.尝试使用获取价值 element.getFirstChild().getNodeValue()

I struggled with the same problem. Try to get the value using element.getFirstChild().getNodeValue()

我得到了正确的值

这篇关于jaxb解组xsd中的anytype元素为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆