This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Deserializing a Stream of Children Using XStream  RSS feed

Reginald Blank
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an XML file of the following form:

I would like to ignore (skip) the Ignore tag.
I don't want to deserialize the Children tag itself.
I want to read the Child tags one at a time using XStream.createObjectInputStream(...).
I don't want to use annotations and I have no control over the XML format.

I can skip the ignore tag using:

which seems a bit hacky.

Unsurprisingly I get the following exception for the Children tag:

com.thoughtworks.xstream.mapper.CannotResolveClassException: Children

It doesn't look like I can use xpaths in the XStream.alias(...) method which would have been nice.
I would like to set the 'root' to be Root/Children tag but I can't see how to do that either.
The solution needs to be memory efficient, i.e. serial not DOM based.
Any help greatly appreciated.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!