Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting XML

Status
Not open for further replies.

slamnwire

Programmer
Aug 23, 2001
1
US
I'm working with the DOM in VB, and would like to sort the child elements of a node by their attributes. Can this be done and can you provide an example?

For example...

<FruitStand>
<Apples>
<Apple AppleType=&quot;Granny Smith&quot; Color=&quot;Green&quot;/>
<Apple AppleType=&quot;Macintosh&quot; Color=&quot;Red&quot;/>
...
<Apple AppleType=&quot;Red Delicious&quot; Color=&quot;Red&quot;/>
</Apples>
</FruitStand>

I might for instance want to sort by Color.
 
slamnwire,

the best bet would be using xsd:

<?xml version=&quot;1.0&quot; ?>
<xs:schema xmlns:xs = &quot;
<xs:element name = &quot;Apple&quot;>
<xs:complexType>
<xs:sequence name= &quot;red&quot; type = &quot;xs:string&quot; />
<xs:sequence name= &quot;green&quot; type = &quot;xs:string&quot; />
</xs:complexType>
</xs:element>

</xml>

this might help since you did not give a full detail beyond sort by color?

Aaron
 
slamnwire -

You know, of course, that the XML spec does not imply that elements appear in any particular order?

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top