Friday 15 July 2011

xml - UnmarshalException while using JAXB -



xml - UnmarshalException while using JAXB -

i trying run code:

jaxbcontext jaxbcontext = jaxbcontext.newinstance(objectfactory.class); unmarshaller unmarshaller = jaxbcontext.createunmarshaller(); tags tags = (tags) unmarshaller.unmarshal(new file("tags.xml"));

however, error:

javax.xml.bind.unmarshalexception: unexpected element (uri:"", local:"tags"). expected elements (none)

how can prevent exception occuring? root element:

@xmlrootelement(name = "tags")

jaxb doesn't know classes should process.

jaxbcontext jaxbcontext = jaxbcontext.newinstance(tags.class); unmarshaller unmarshaller = jaxbcontext.createunmarshaller(); tags tags = (tags) unmarshaller.unmarshal(new file("tags.xml"));

xml jaxb unmarshalling

No comments:

Post a Comment