tags:

views:

183

answers:

2

I have a XML structure somewhat like this:

<root>
    <a/>
    <b/>
    <b/>
    <a/>
    <a/>
</root>

My XSD looks like this:

<xs:element name="root">
    <xs:complexType>
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:element ref="a"/>
                <xs:element ref="b"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="a" type="xs:string" />
<xs:element name="b" type="xs:string" />

I.e. i have a random sequence of two different sub tags.

Using XMLBeans i get a Root object with access methods: getAArray(), getBArray()

And here's my problem:
The tags are grouped by name and the original order (a,b,b,a,a) is lost.
But i need to know the order of those elements.

What is the best / easiest way to do that with XMLBeans?

+4  A: 

Try

xml.selectPath("./*")

Hes Siemelink
Exactly what i wanted. Returns the parsed XMLBeans. Thank you very much.
Stroboskop
+1  A: 

ok i got it. the selectPath method of XmlObject returns an array of objects so it gives the sequence.