• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

bean classes from an XML file with a lot of nested tags, using XSTREAM

 
Ranch Hand
Posts: 563
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an XML file that has a lot of nested tags and nested tags.

A bit like this:

<bla>
<stuff1>aa</stuff1>
<stuff2>bb</stuff�>
<stuff3>
<stuff4>
<stuff5>cc</stuff5>
<stuff6>dd</stuff6>
<stuff7>ee</stuff7>
</stuff4>
<stuff8>
<stuff9>ff</stuff9>
<stuff10>gg</stuff10>
<stuff11>hh</stuff11>
</stuff8>
<stuff8>
<stuff81>ff</stuff81>
<stuff82>gg</stuff82>
<stuff83>hh</stuff83>
</stuff8>
<stuff12>
<stuff13>ii</stuff13>
<stuff14>jj</stuff14>
<stuff15>kk</stuff15>
</stuff12>
<stuff12>
<stuff13>ll</stuff13>
<stuff14>mm</stuff14>
<stuff15>nn</stuff15>
</stuff12>
</stuff3>
<stuff3>
<stuff4>
<stuff5>csdc</stuff5>
<stuff6>dfd</stuff6>
<stuff7>ege</stuff7>
</stuff4>
<stuff8>
<stuff9>ffr</stuff9>
<stuff10>gyg</stuff10>
<stuff11>huh</stuff11>
</stuff8>
<stuff8>
<stuff81>fjf</stuff81>
<stuff82>gfg</stuff82>
<stuff83>hdh</stuff83>
</stuff8>
<stuff12>
<stuff13>iwi</stuff13>
<stuff14>jej</stuff14>
<stuff15>kkd</stuff15>
</stuff12>
</stuff3>
</bla>

stuff3 is unbounded, i mean it can repeat a lot of times, same with stuff4, stuff8, stuff12.

So, I want to map this XML file to Javabeans.

public class Bla {
private String stuff1;
private String stuff2;
private List stuff3;
}

public class Stuff3 {
private List Stuff4;
private List Stuff8;
private List Stuff12;
}


public class Stuff4 {
private string stuff5;
private string stuff6;
private string stuff7;
}

But I am a bit confused with the lists here. How does XStream handle that ?
I cannot find many advanced examples unfortunately.
Any advice, help would be much appreciated !
Thanks in advance
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic