Looping XML in VB.net



What I would like to do is take a bunch of Prefixes for names that are in an XML file (Mr, Mrs, Dr....) loop through them, and put them each into a listbox, so the user can just click whichever they need.


There must be an easier way than this:



<ObitSettings>
<Prefixes>
Mr.
</Prefixes>
<Prefixes>
Mrs.
</Prefixes>
<Prefixes>
Rev.
</Prefixes>
<Prefixes>
Fr.
</Prefixes>
<Prefixes>
......


I had it another way where each Prefix had its own node:



<Prefixes>
<Mister>Mr.</Mister>
<Missus>Mrs.</Missus>
...
</Prefixes>


But that way was giving me everything in one long string, resulting in only on item in the listbox.


I kind of liked that last way, as it seemed more descriptive, so if it is possible I would like to be able to write the XML like that. If not, then I'll go with whatever works.


I was using both For Each...Loops and For i...Loops. Something like starting at <Prefixes> then looking at the first node, getting it's text, then the second, and so on?


No comments:

Post a Comment