Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding reading using XMLbeans

 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please help me about this XMLbeans example.

I have an XSD, the person.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="person-group">
<xs:complexType>
<xs:sequence>
<xs:element name="person" type="person" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="person">
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="age" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:schema>

person.xml

<?xml version="1.0" encoding="UTF-8"?>
<person-group>
<person>
<name>Mohan</name>
<age>12</age>
</person>
<person>
<name>Sohan</name>
<age>15</age>
</person>
<person>
<name>Rohan</name>
<age>16</age>
</person>
<person>
<name>Jane</name>
<age>20</age>
</person>
<person>
<name>PC</name>
<age>29</age>
</person>
</person-group>

I geneated the jar using scomp command

I want to read this XML using XMLBeans in one object and iterate it to all other person object.

Q: Is it possible to get all person object in one object say PersonGroup ?
Q: How to iterate over person object ?


Kindly reply.

Thanks,

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic