【发布时间】:2012-03-20 21:43:16
【问题描述】:
我使用 .xsd 文件生成 Java 类,使用 XML 文件,我需要解组。
我正在使用此代码:
JAXBContext objJAXBContext = JAXBContext.newInstance("my.test");
// create an Unmarshaller
Unmarshaller objUnmarshaller = objJAXBContext.createUnmarshaller();
FileInputStream fis = new FileInputStream("test.xml");
JAXBElement<Root> objMyRoot = (JAXBElement<Root>) objUnmarshaller.unmarshal(fis);
Root mRoot = objMyRoot.getValue();
我收到此错误:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Root"). Expected elements are (none)
我见过很多解决方案,但在我的项目中没有任何效果。
我可以尝试做什么?
【问题讨论】:
-
您可以先向我们展示
test.xml的内容。
标签: exception jaxb unmarshalling