views:

233

answers:

1

I would please like to retrieve data from a xml file based on user input with date. I would like to compare the user input date with the date in the xml file and if its greater than the xml file date, it should retrieve it. my linq query looks like this thanks in advance.

XDocument xmlDoc = XDocument.Load(Server.MapPath("xml/data1.xml"));

var hotels = from hotel in xmlDoc.Descendants("Table")
             where Double.Parse(pplTextBox.Text) <= Double.Parse(hotel.Element("NO_OF_PEOPLE").Value) && 
             DateTime.Parse(DateTextFrom.Text) > DateTime.Parse(hotel.Element("DATE_TO").Value)
             select new
             {
                RoomCost = hotel.Element("ROOM_COST").Value,
                RoomType = hotel.Element("ROOM_TYPE").Value,
                HotelName = hotel.Element("HOTEL_NAME").Value,
                NoOfPeople = hotel.Element("NO_OF_PEOPLE").Value,
                Smoking = hotel.Element("SMOKING").Value,
                Restaurant = hotel.Element("RESTAURANT").Value,
                //Location = hotel.Element("HOTEL_AREA").Value,
                //AvailableDate = hotel.Element("DATE_TO").Value
             };

    GridView1.DataSource = hotels.ToList();
    GridView1.DataBind();
A: 

can you use?

AvailableDate = (hotel.Element("DATE_TO").Value > inputDate) ? 
                     hotel.Element("DATE_TO").Value : inputDate
Preet Sangha
its not working with AvailableDate, is there any references i need to add? Thanks in advance.