Hi all,
I'm working on an ASP app in which I need to load an XML file and the display a dropdownlist which when clicked it shows the unique values for a specific node:
Ex.
I would like my dropdown list to display :
fiction
romance
I'm currently able to display:
fiction
fiction
romance
romance
Here's the code I have:
Could someone point me in the write direction as to how to get the unique values for type?
Thank you!
I'm working on an ASP app in which I need to load an XML file and the display a dropdownlist which when clicked it shows the unique values for a specific node:
Ex.
Code:
<?xml version="1.0"?>
<!-- A fragment of a book store inventory database -->
<bookstore xmlns:bk="urn:samples">
<book genre="novel" publicationdate="1997" bk:ISBN="1-861001-57-8">
<title>Pride And Prejudice</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
[b][COLOR=red]<type>fiction</type>[/color][/b]
</book>
<book genre="novel" publicationdate="1992" bk:ISBN="1-861002-30-1">
<title>The Handmaid's Tale</title>
<author>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
</author>
[b][COLOR=red]<type>fiction</type>[/color][/b]
</book>
<book genre="novel" publicationdate="1991" bk:ISBN="1-861001-57-6">
<title>Emma</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
[b][COLOR=red]<type>romance</type>[/color][/b]
</book>
<book genre="novel" publicationdate="1982" bk:ISBN="1-861001-45-3">
<title>Sense and Sensibility</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
[b][COLOR=red]<type>romance</type>[/color][/b]
</book>
</bookstore>
I would like my dropdown list to display :
fiction
romance
I'm currently able to display:
fiction
fiction
romance
romance
Here's the code I have:
Code:
XmlDocument xDoc = new XmlDocument();
xDoc.Load(xmlPath);
[b]XmlNodeList audienceList = xDoc.SelectNodes("/bookstore/book/type");[/b]
foreach (XmlNode n in audienceList)
{
ListItem item = new ListItem(n.InnerText, n.InnerText);
this.selection.Items.Add(item);
}
Could someone point me in the write direction as to how to get the unique values for type?
Thank you!