Saturday, 17 August 2013

Java XStream starting level

Java XStream starting level

I have an XML document like
<ListOfCats>
<Cat>
<Name>Mittens</Name>
</Cat>
<ListOfCats>
that I'm deserializing using XStream like
ListOfCats mewlings = (ListOfCats)xstream.fromXML(xml);
but then I have to access them like
mewlings.getCat().get(1).getName()
to get the names.
I'd much rather prefer to just have an ArrayList of Cats instead of a
ListOfCats of Cats so I could access them like
mewlingArray[1].getName();
Is it possible to set the starting level of XStream so I can skip the
<ListOfCats>?

No comments:

Post a Comment