Hi, Hope everybody is file here....
I have an xml like this
Now I want an string array of holidays for year 2010
I'm trying something like
Can you please suggest how to extract the holidays for year 2010 from the xml.
Thanks :)
Edit: And also how do i do the same when the xml is of the form
I have an xml like this
Code:
<?xml version="1.0" encoding="utf-8" ?>
<Holidays>
<year year="2010">
<holiday day="03/01/2010" />
<holiday day="03/02/2010" />
</year>
<year year="2011">
<holiday day="03/01/2011" />
<holiday day="03/02/2011" />
<holiday day="03/03/2011" />
</year>
</Holidays>
I'm trying something like
Code:
XDocument holidays = XDocument.Load("path to xml/ xmlreader");
var days = from el in holidays.Root.Elements("year")
where el.Attribute("year").Value == "2010"
select el.Elements("holiday");
foreach (var date in days)
{
// But here date is not what i want like '03/01/2010' or '03/02/2010'
}
Thanks :)
Edit: And also how do i do the same when the xml is of the form
Code:
<?xml version="1.0" encoding="utf-8"?>
<Holidays>
<Year Year="2010">
<Holiday>"03/01/2010"</Holiday>
<Holiday>"05/27/2010"</Holiday>
</Year>
<Year Year="2011">
<Holiday>"03/01/2011"</Holiday>
<Holiday>"05/27/2011"</Holiday>
</Year>
</Holidays>
Comment