PLEASE HELP!
I'm writing a function to populate DropDownLists from and xml file. I
am having a problem getting my XPathNavigator to select any nodes when
I attach a schema to my xml document.
Xml Doc: Dropdown.xml
XML Schema: Dropdown.xsd
Here is my XML Document...
<?xml version="1.0" encoding="utf-8" ?>
<DropDownList s xmlns="http://tempuri.org/DropDown.xsd">
<DropDownList name="DataSourc e">
<Option name="SqlServer " value="SqlServe r" />
<Option name="Oracle" value="Oracle" />
<Option name="DB2" value="DB2" />
</DropDownList>
<DropDownList name="Language" >
<Option name="ASP" value="ASP" />
<Option name="ASP.Net" value="ASP.Net" />
</DropDownList>
</DropDownLists>
....and here is my code...
private void LoadDropdownMen u(string DropDownName)
{
DropDownList GenericDropDown =
(DropDownList)F indControl(Drop DownName);
XPathDocument xpDoc = new XPathDocument(S erver.MapPath(" .") +
"\\Dropdown.xml ", XmlSpace.Preser ve);
XPathNavigator xNav = xpDoc.CreateNav igator();
XPathNodeIterat or xNode =
xNav.Select("/DropDownLists/DropDownList[@name='" + DropDownName +
"']/Option");
while(xNode.Mov eNext())
{
GenericDropDown .Items.Add(new
ListItem(xNode. Current.GetAttr ibute("name","" ),xNode.Current .GetAttribute(" value","http://tempuri.org/DropDown.xsd")) );
}
}
I don't get any nodes returned in my XPathNodeIterat or using the above
xml file and code. If I remove xmlns="http://tempuri.org/DropDown.xsd"
from my xml file, everything works perfectly.
I want to be able to use a schema with my xml file. Can someone please
explain what I am doing wrong?
Thanks in advance.