marshel and unmarshel with jaxb?

E

Elhanan

i'm trying to use jaxb with eclipse , I have allready generated the
classes and they are ok but if try :
j
final JAXBContext
context=JAXBContext.newInstance(Party.class.getPackage().getName());
Unmarshaller
unmarshaller=context.createUnmarshaller();
Marshaller ms=context.createMarshaller();


DocumentBuilderFactory f =
DocumentBuilderFactory.newInstance();
DocumentBuilder b= f.newDocumentBuilder();
Document d = b.parse("test001.xml");
// Unmarshall the document


final RespParty respParty = (RespParty)
unmarshaller.unmarshal(d);


javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: unexpected root element (uri:"",
local:"party"). Expected elements are <{http://nokis.baw.de/}party>]


so instead of using the document object, i used a file object and it
was ok, but, if i try to create a objects and turn it to xml i can't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top