XML : how to search through all Elements in xml , using c#

This is my xml feed.It has more than this.

   <Cproducts>     <Availability>          <Departure>            <Date>2015-12-03T00:00:00.0000000+00:00</Date>            <Pricing>              <Price>                <Type>ADT</Type>                <Value>175.00</Value>                <Qty>20</Qty>              </Price>              <Price>                <Type>CHD</Type>                <Value>95.00</Value>                <Qty>5</Qty>              </Price>              <Price>                <Type>INF</Type>                <Value>0.00</Value>                <Qty>5</Qty>              </Price>              <Price>                <Type>FAM</Type>                <Value>0.00</Value>                <Qty>0</Qty>              </Price>              <Price>                <Type>SEN</Type>                <Value>175.00</Value>                <Qty>20</Qty>              </Price>            </Pricing>          </Departure>          <Departure>            <Date>2015-12-06T00:00:00.0000000+00:00</Date>            <Pricing>              <Price>                <Type>ADT</Type>                <Value>175.00</Value>                <Qty>20</Qty>              </Price>              <Price>                <Type>CHD</Type>                <Value>95.00</Value>                <Qty>5</Qty>              </Price>              <Price>                <Type>INF</Type>                <Value>0.00</Value>                <Qty>5</Qty>              </Price>              <Price>                <Type>FAM</Type>                <Value>0.00</Value>                <Qty>0</Qty>              </Price>              <Price>                <Type>SEN</Type>                <Value>175.00</Value>                <Qty>20</Qty>              </Price>            </Pricing>          </Departure>      <Availability>   </Cproducts>      

In my case I want to go through all available dates.that means when user select a date[from the form], then according to that date ,other data should provide.to do that I have to look through all available dates.how can I do that. this is my code in MVC.

    public void getDatas(string destination, string cruisetype, string datetime)          {              XElement rootele = XElement.Load(Server.MapPath("~/XmlFiles/CruiseData/cruiseprodutstwo.xml"));                var selecttoDate = rootele.Elements("Cproducts").Elements("Availability").Elements("Departure").Elements("Date"); //here I want to get the data that the [date == datetime]    

No comments:

Post a Comment