Hello, the answer is clear: *) you use Castor through the static unmarshal method *) you use no mapping definition *) I guess that you have not generated the code => the result of this mode is that the class to fill with the information of the XML is identified through matching names... the element 'ins' has no matching Java class but the element 'instrument' has; but as in the second example 'ins' needs to be mapped first which has no corresponding class...
One solution would be to use a mapping file -> see http://www.castor.org/xml-mapping.html Hope this helps to understand how Castor works and how you could solve the problem Joachim On 07/04/2008, poijava <[EMAIL PROTECTED]> wrote: > > Hi, > > I am trying to unmarshall an XML document below: > > <?xml version="1.0" encoding="UTF-8"?> > <instrument> > <date>04-Feb-2008</date> > <bbg>A2A IM Equity</bbg> > <sedol>5499131</sedol> > <isin>IT0001233417</isin> > <bookqty></bookqty> > </instrument> > > Using the following code: > > Instrument instrument = (Instrument) Unmarshaller.unmarshal( > Instrument.class, new FileReader("Instrument.xml")); > > System.out.println(instrument.getBbg()); > > this works fine except when I have a root element e.g. > > <?xml version="1.0" encoding="UTF-8"?> > <ins> > <instrument> > <date>04-Feb-2008</date> > <bbg>A2A IM Equity</bbg> > <sedol>5499131</sedol> > <isin>IT0001233417</isin> > <bookqty></bookqty> > </instrument> > </ins> > > The all the fileds in my Instrument object are null!! > > Can anyone please help? > > Thanks, > G > -- > View this message in context: > http://www.nabble.com/Unmarshalling-Root-node-problem-tp16537521p16537521.html > Sent from the Castor - Dev mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email