基于此xml
<Reservation>
<SeatEconomy>2</SeatEconomy>
<SeatFirst>14</SeatFirst>
</Reservation>
如何根据特定条件显示MessageBox?即伪代码:
//case 1 Economy Class
if(elementName==SeatEconomy)
MessageBox.Show(string.Format("Economy class assigned seat {0}",
name6.ToString()), "Results", MessageBoxButtons.YesNoCancel);
//case 2 First Class
if(elementName==SeatFirst)
MessageBox.Show(string.Format("First class assigned seat {0}",
name6.ToString()), "Results", MessageBoxButtons.YesNoCancel);
到目前为止我所做的事情:
XDocument info = XDocument.Load("reservation.xml");
var result = from reservat in info.Descendants("Reservation")
let ep = reservat.Element("SeatEconomy")
select ep;
var compare = result.FirstOrDefault();
//how can I select SeatFirst and do comparison between SeatFirst
and SeatEconomy?
提前致谢。