I have written such a code in order to parse the attributes in a xml file. It works great.
But I want to filter content according to a parameter from the query.
For example, when I type like products.aspx?type=fruit, I want to show only products whose types are fruit.
How can i do it?
Sample XML file.
<NewDataSet>
<product type="fruit" name="orange" pcode="100" />
<product type="car" name="audi" pcode="0231" />
</NewDataSet>
Thanks in advance.
<%
dim xmldoc as XmlDocument = new XmlDocument()
xmldoc.Load(Server.MapPath("products.xml"))
dim xmlnodes as XmlNodeList = xmldoc.SelectNodes("NewDataSet/Product")
DataGrid1.DataSource = xmlnodes
DataGrid1.DataBind ()
%>
<asp:DataGrid id="DataGrid1" AutoGenerateColumns="False" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="ProductCode">
<ItemTemplate>
<%#CType(Container.DataItem, System.Xml.XmlNode).Attributes("pcode").value%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>