• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Process multiple node occurences using JAXB

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am quite new to JAXB. Wondering if I could get some pointers how I could go about processing a XML which would be something like -

<Group>
<Family>
<Person>
<Name>John Doe</Name>
<Address>100 Main Street, Chicago, IL, 60000</Address
<Age>40</Age>
</Person>
<Children>
<Name>John Doe Jr.</Name>
<Age>7</Age>
</Children>
</Family>
<Family>
<Person>
<Name>Jack Doe</Name>
<Address>200 Main Street, Chicago, IL, 60000</Address
<Age>42</Age>
</Person>
<Children>
<Name>Jack Moe Jr.</Name>
<Age>8</Age>
</Children>
</Family>
</Group>

The <Family> nodes need to be recursively process. Is there a easy way to generate a schema file based of any xml file? Would the JAXB compiler while generating the Java object model based of the schema would also generate the required class to handle lists of these individual nodes (here it is the Children node, I guess) of that sort or it's the developer who has to implement separately to handle this kind of lists?
Would really appreciate if I could some lead on this.
Some sample code would be great too! By the way I already have codes using JAXP APIs to do what I need to have. But I am bound to use JAXB because of existing application uses that.

Thanking you all.
 
Tariq Ahsan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
correction should be (here it is the Family node, I guess) instead of (here it is the Children node, I guess) in my earlier posting.
Sorry!
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic