I want to filter xml based on query string
my xml is like this
<Categories>
<Category>
<Title>Food1<Title>
<Cat>Cat3</Cat>
<Duration>12/1/2009-12/1/2011</Duration>
<Description>Who is hungry</Description>
<Category>
<Category>
<Title>Food1<Title>
<Cat>Cat2</Cat>
<Duration>12/1/2009-12/1/2011</Duration>
<Description>Who is hungry</Description>
<Category>
<Category>
<Title>Food1<Title>
<Cat>Cat1</Cat>
<Duration>12/1/2009-12/1/2011</Duration>
<Description>Who is hungry</Description>
<Category>
<Category>
<Title>Food1<Title>
<Cat>Cat1</Cat>
<Duration>12/1/2009-12/1/2011</Duration>
<Description>Who is </Description>
<Category>
I want filtering based on query string like if
- ?food=Food1( it should display all)
- ?food=Food1&Cat=Cat1 (it should dispalay last 2)
- ?Cat=Cat1&Description=Who is (display last1)
- ?food=Food1&Cat=Cat1&Description=Who is hungry(3rd one)
I want to display this in repeater.I am using XPathIterator to iterate it and bind it into repeater.
my code till now is this
string _Cat = HttpContext.Current.Request.QueryString["Cat"].ToString();
string _description = HttpContext.Current.Request.QueryString["description"].ToString();
string _food = HttpContext.Current.Request.QueryString["food"].ToString();
XmlDocument doc = new XmlDocument();
doc.Load("/Finder.xml");
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expression = nav.Compile("/Categories/Category[Cat='_Cat and title='_food' and Description='_description']/*");
XPathNodeIterator iterator = nav.Select(expression);
//but this will only solve case 4) i know i can write similar for other three but i want this thing to be dynamic. Like we have it in amazon. Filter just add according to the selection u make it.so may there is no query string , may be 1,may be 2 so i need to check on that
and then i m binding this iterator to repeater using datatable
Any idea how to acheive this?