• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Process multiple node occurences using JAXB

 
Tariq Ahsan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic