私はこのようなXMLを持っています:
<PrayerTime
Day ="1"
Month="5"
Fajr="07:00"
Sunrise="09:00"
Zuhr="14:00"
/>
このようなクラス:
public class PrayerTime
{
public string Fajr { get; set; }
public string Sunrise { get; set; }
public string Zuhr { get; set; }
}
そして、このような値を取得するための何か:
XDocument loadedCustomData = XDocument.Load("WimPrayerTime.xml");
var filteredData = from c in loadedCustomData.Descendants("PrayerTime")
where c.Attribute("Day").Value == myDay.Day.ToString()
&& c.Attribute("Moth").Value == myDay.Month.ToString()
select new PrayerTime()
{
Fajr = c.Attribute("Fajr").Value,
Sunrise = c.Attribute("Sunrise").Value,
};
myTextBox.Text = filteredData.First().Fajr;
現在の時刻に基づいて、時間がFajrの値とSunriseの値の間にある場合、myTextBoxはFajrの値を表示する必要があるとどのように言うことができますか。現在の時刻の値が日の出とZuhrの間にある場合、Zuhrを表示しますか?
myTextBox2に属性名を表示するにはどうすればよいですか?たとえば、myTextBoxは値「07:00」を示し、myTextBox2は「Fajr」を示しますか?