Hi Ramjet, Ramjet wrote:
> Hello, > > I have a double wammy being new to Java and XStream. I am trying to > determine how I am using XStream incorrectly and not figuring it out. If > someone could take a quick moment I'm sure it is quite simply me not using > the correct syntax. > > TIA > JB > This is on stackoverflow if you want to get some points. > http://stackoverflow.com/questions/13588780/error-converting-xml-to- custom-object > > > CannotResolveClassException error. The detail message is Exercises > (id=#####....). > > My XML doc looks like this: > > <?xml version="1.0" encoding="UTF-8"?><Exercises count="15"><Exercise> > <AccountName>PersonA</AccountName> > ..... > </Exercise> > <Exercise> > ..... > </Exercise> > ...More Exercise Nodes...</Exercises> > > My Custom Object > > public class LiftData{public String AccountName;...etc} > > Code implementation > > ArrayList<LiftData> _ldData = null;XStream xstream = new XStream();try { > Object x = xstream.fromXML(new FileInputStream(fle_LftData), > _ldData);} XStream is mode in first line to convert Java objects to XML and back. You can modify the default setup of XStream to read different XML structures, but it will not to this our-of-the-box. However, tweaking XStream to *read* a different XML format is error-prone and annoying, because you have to guess form the exception, what part of your XML does not make sense to XStream. What you will normally do, is to tweak XStream until it *writes* the same XML you want to read. If it produces the same output, it will normally also read it ;-) Cheers, Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
