>(prefixes) > (prefix Title="Mr" /) > (prefix Title="Mrs" /) > (prefix Title="Miss" /) > (prefix Title="Ms" /) > (prefix Title="Prof" /) > (prefix Title="Capt" /) > (prefix Title="Dr" /) > (prefix Title="Rev" /) >(/prefixes) >>
>(states) > (state Name="Alabama" ID="AL" /) > (state Name="Alaska" ID="AK" /) > (state Name="Arizona" ID="AZ" /) > (state Name="Arkansa" ID="AR" /) > (state Name="California" ID="CA" /) >>
>(states) > (state) > (Name)Alabama(/Name) > (ID)AL(/ID) > (/state) >(/states) >>
>(asp:XmlDataSource ID="xmlPrefixes" runat="server" DataFile="~/Xml/Prefixes.xml" XPath="prefixes/prefix" /) >(mm:mmRADComboBox ID="cboNamePrefix" runat="server" > DataSourceID="xmlPrefixes" DataTextField="Title" DataValueField="Title" > Width="60px" /) >>Couldn't get this to work so I resorted to code and tried this:
>XmlDocument doc = new XmlDocument(); >doc.Load(Server.MapPath("/Xml/States.xml")); >XmlNodeList states = doc.SelectNodes("//state/Name"); > >for (int i = 0; i < states.Count; i++) >{ > this.cboState.Items.Add(new Telerik.Web.UI.RadComboBoxItem(states[i].InnerText, states[i].InnerText)); >} >>In code the xml document loads up just fine, but navigating the nodes is the problem
public class StateInfo { public string Id { get; set; } public string Name { get; set; } }Then:
XDocument doc = XDocument.Load("States.xml"); var theStates = from state in doc.Descendants("state") select new StateInfo() { Name = (string)state.Attribute("Name"), Id = (string)state.Attribute("ID") };and you should be able to bind to theStates. Could bind in markup using WPF but I don't know how you'd do that in ASP.NET...