nisarkhan
asked on
Loading XML data in Dropdownlist
Hi,
I have a XML file that I want to load all the child elements(TopicName) into a Dropdownlist.
Thanks
I have a XML file that I want to load all the child elements(TopicName) into a Dropdownlist.
Thanks
<content type="application/xml">
<CatalogItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="sitename.xsd">
<CatalogSource Acronym="ABC" OrganizationName="ABC Corporation" />
<CatalogItem Id="3212" CatalogUrl="urlname">
<ContentItem xmlns:content="sitename.xsd" TargetUrl="url">
<content:SelectionSpec ClassList="" ElementList="" />
<content:Language Value="eng" Scheme="ISO 639-2" />
<content:Source Acronym="ABC" OrganizationName="ABC Corporation1" />
<content:Topics Scheme="ABC">
<content:Topic TopicId="1" TopicName="Marketing1" />
<content:Topic TopicId="11" TopiccName="Coverage1" />
</content:Topics>
</ContentItem>
</CatalogItem>
</CatalogItems>
<CatalogItem Id="3212" CatalogUrl="urlname">
<ContentItem xmlns:content="sitename.xsd" TargetUrl="url">
<content:SelectionSpec ClassList="" ElementList="" />
<content:Language Value="eng" Scheme="ISO 639-2" />
<content:Source Acronym="ABC" OrganizationName="ABC Corporation2" />
<content:Topics Scheme="ABC">
<content:Topic TopicId="2" TopicName="Marketing2" />
<content:Topic TopicId="22" TopiccName="Coverage2" />
</content:Topics>
</ContentItem>
</CatalogItem>
</CatalogItems>
<CatalogItem Id="3212" CatalogUrl="urlname">
<ContentItem xmlns:content="sitename.xsd" TargetUrl="url">
<content:SelectionSpec ClassList="" ElementList="" />
<content:Language Value="eng" Scheme="ISO 639-2" />
<content:Source Acronym="ABC" OrganizationName="ABC Corporation3" />
<content:Topics Scheme="ABC">
<content:Topic TopicId="3" TopicName="Marketing3" />
<content:Topic TopicId="33" TopiccName="Coverage3" />
</content:Topics>
</ContentItem>
</CatalogItem>
</CatalogItems>
</content>
You can use xmldatasource.
DropDownList ID="DropDownList1" runat="server" DataSourceID="myXML" DataTextField="TopicName" DataValueField="TopicId" />
<asp:XmlDataSource ID="myXML" runat="server" DataFile="~/myXMLFile.xml" XPath="xpath of your element" />
DropDownList ID="DropDownList1" runat="server" DataSourceID="myXML" DataTextField="TopicName" DataValueField="TopicId" />
<asp:XmlDataSource ID="myXML" runat="server" DataFile="~/myXMLFile.xml"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://forums.asp.net/t/999571.aspx/1