marshel and unmarshel with jaxb?

Discussion in 'Java' started by Elhanan, Feb 17, 2006.

  1. Elhanan

    Elhanan Guest

    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.
     
    Elhanan, Feb 17, 2006
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.