Determine order of different elements in a structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • !NoItAll
    Contributor
    • May 2006
    • 297

    #1

    Determine order of different elements in a structure

    I have a structure
    Code:
    Structure Dogs
       Dim Boxers as Dog()
       Dim Pitbulls as Dog()
       Dim Mutts as Dog()
    End Structure
    
    Structure Dog
       Dim Color as String
       Dim Name as String
    End Structure
    I am deserializing this structure from an XML file

    Code:
    <Dogs>
       <Pitbulls>
           <Dog>
               <Color>Brown</Color>
               <Name>Charlie</Name>
           </Dog>
           <Dog>
               <Color>Black</Color>
               <Name>Hermione</Name>
           </Dog>
       </Pitbulls>
       <Mutts>
           <Dog>
               <Color>Tan</Color>
               <Name>Riley</Name>
           </Dog>
           <Dog>
               <Color>Red</Color>
               <Name>Sam</Name>
           </Dog>
       </Mutts>
       <Boxers>
           <Dog>
               <Color>Tortoise</Color>
               <Name>Sargent</Name>
           </Dog>
           <Dog>
               <Color>White</Color>
               <Name>Missy</Name>
           </Dog>
       </Boxers>
    </Dogs>
    Notice that the order of the structure and the order of the XML is different - that shouldn't matter. But... the order I present the data to the user is important. The data was entered in a specific order and needs to be presented in the same order.
    So based on the XML I need to present the data as follows.


    Pittbulls
    Charlie/Brown
    Hermione/Black
    Mutts
    Riley/Tan
    Sam/Red
    Boxers
    Sargent/Tortoise
    Missy/White


    So the structure fills out just fine, but the order in the XML file is different each time and I need to honor that in my display of the data. Ok - my actual program is not about dogs, this is just for illustrative purposes.
    Does anyone have a suggestion (or is this too obtuse)?

    !NoItAll
Working...