RicardO
RicardO

Reputation: 1229

Using regular expressions in c#

Following is the source:

 <option value="ON">Ontario
 <option value="PE">Prince Edward Island

I want to return a List or array of strings in the following format:

 s(0) = "ON,Ontario" 
 s(1) = "PE,Prince Edward Island"

How to create a function to return this List<string>

Upvotes: 0

Views: 110

Answers (1)

BinaryTox1n
BinaryTox1n

Reputation: 3556

It appears that you have an XML file and would like to retrieve information from nodes (attributes and contents).

See MSDN Documentation on XmlReader

Regular expressions would not be ideal for this purpose.

EDIT: Now it looks like you want info from a DropDownList from an aspx page. To do that, you need:

List<string> list = new List<string>();
foreach(ListItem li in DropDownListID.Items)
{
    string value = li.Value.ToString();
    string text = li.Text;
    list.Add(string.Concat(value, ", ", text));
}

Upvotes: 2

Related Questions