Women in Technology

Hear us Roar



Article:
  XML-Java Data Binding Using XMLBeans
Subject:   how to traverse multiple elements
Date:   2008-03-05 00:26:25
From:   bhandari4u
Hi,
I have a number of person in a person group.
persongroup has the method of getting only the first person. How do I move my persongroup object to next person so that getPerson returns me the second person. PersonGroup object doesn't even has getPersonaArray method to return all the person's in my XML document. Here is my xml document.


<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-group>


and my 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:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:int"/>
</xs:complexType>
</xs:schema>