I used the .xsd file to generate Java classes, and with the XML file I need to undo the marker.
I am using this code:
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();
and I get this error:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Root"). Expected elements are (none)
I have seen many solutions, but nothing works in my project.
What can I do?
Vítor Nóbrega
source share