0

I have a list of items which is the result of a xslt over and xml file. The list is ordered in descending order, as needed.

Below is the list as it appears in the browser:

<?xml version="1.0"?> -<seasons> <season>2014</season> <season>2013</season> <season>2012</season> </seasons>

(Sorry, I am new at placing code inline, can't get the indented structure into it but it does show correctly in the browser)

Can you show me how to a dropdownlist with this result? I am using asp.net and c#.net.

Thanks for any help. I am an experienced programmer in VBA but new at .net.

Avdecha
  • 3
  • 1

1 Answers1

0

So first of all you have to make a method to deserialize the xml (I suppose you have it as a string) into a list. To do that I suggest following this post: How can I transform XML into a List<string> or String[]?

I am reffering to the first two response, use whichever you like most. And then you can make the binding several ways, to get the data to the browser. You send the list to the View and use razor syntax / html helpers. here is an example: first answer is what I'm talking about:

Populating a razor dropdownlist from a List<object> in MVC

if you don't want helpers you can also create a loop using razor and then populate the fields in the select. OR you could do ajax calls using jquery, it depends on how much control you want. Personally I don't know yet which is better, using razor syntax and helpers, or using a lot of javascript and ajax calls. Sor far I can say I've used a lot of js and ajax, and very little razor and helpers.

EDIT Sorry, after reading again I see that you have your XML as a document - you mentioned something about opening it in browser. here is another post and I believe the 1st answer is exactlly what you need: How to Deserialize XML document

Community
  • 1
  • 1
Vlad
  • 536
  • 1
  • 5
  • 18
  • Hi Vlad, going on your last link 'How to deserialize etc..', where do I place these sets of code? Do I create a '.cs' file in the App_Code folder? I am sorry for the rather helpless question, really need to get a little more explanation. Thanks ahead. – Avdecha Oct 10 '13 at 21:04