Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Load Holidays from an XML file

To load holidays in the scheduler, you can use XML file which is actually a serialized HolidayBaseCollection object.

This file contains holidays for several countries in the following format:

XML
<Holidays>
<Holiday Date="04/25/2012 00:00:00" DisplayName="Anzac Day" Location="Australia">
<Holiday Date="04/25/2013 00:00:00" DisplayName="Anzac Day" Location="Australia">
<Holiday Date="04/25/2014 00:00:00" DisplayName="Anzac Day" Location="Australia">
<Holiday Date="04/25/2015 00:00:00" DisplayName="Anzac Day" Location="Australia">
...
</Holidays>

The Scheduler library provides the supplementary DevExpress.Schedule.Serializing.HolidayCollectionXmlPersistenceHelper class, which is designed to load holidays from the xml file. So, you may obtain a collection of days which are considered holidays for the specific country, and add these holidays to the SchedulerControl.WorkDays collection of a Scheduler Control.

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(path);
HolidayBaseCollection holidays = DevExpress.Schedule.Serializing.HolidayCollectionXmlPersistenceHelper.ObjectFromXml(doc.OuterXml);
var holidaysRussian = from holiday in holidays
                                        where holiday.Location == "Russia"
                                        select holiday;
schedulerControl1.WorkDays.AddRange(holidaysRussian.ToList<Holiday>());