Reading and Writing XML Data
The dbicDropDate control is capable of reading and writing data in an XML format. The data can be read and written as a string (memory variable), or from/to a file. The control is also capable of creating XML for the entire control (including formatting of the control in addition to the data in the collections), or for a a specific class (i.e. DayFormats).
The use of XML makes it easy to create a snapshot of the current data, save it, and then start using it again at some later time. It can also be used to send an XML file to another user so that they can review or continue to work on the data.
Reading and Writing an XML File
The methods used to read and write the XML files are the ReadXMLFile and WriteXMLFile methods. A valid XML file (path and name) can be read from a local drive, a mapped drive, or through a url from a web site. Writing of xml files must be to a local or mapped drive, url's are not supported in the WriteXMLFile method.
NOTE : The collections do not contain a method to read an XML file. The ReadXMLFile method from the main control is able to determine the type of data being read and load it appropriately. For instance, the following routine will read XML data for the control no matter what method was used to create it.
' Read an XML file
dbicDropDate.ReadXMLFile("C:\DropDateXML.xml")
Reading and Writing XML Strings
The dbicDropDate control contains an XMLString property. This property is able to read and write data for the control based on an XML format into or out of a string variable. The DayFormat collection also contain an XMLString property.
NOTE: The XMLString property for the collections is write only. Just like the ReadXMLFile method, the XMLString property for the main control is used to read all types of XML for the control.
Reading and Writing XML Files at Design Time
A powerful feature of the control is its ability to read and write XML files at design time. This can be very useful when upgrading a control that has been formatted using the property page and not through code or a developer wants to share control styles with other developers. The property window for the dbicDropDate control contains an XMLRead and XMLWrite property. When a character string is entered into these fields, an Open or Save File dialog will appear and allow the programmer to read from or write to an XML file. The XMLWrite property will only write data for the entire control (i.e. not individual collection data).
Write Many, Read Once
This refers to the fact that there are a variety of ways to write an XML file write an XML string, but there is only one way to read it. When XML data is written, it can be from the entire control, or from an individual collection. When a write method is invoked the data created will contain the proper header identifying the type of data in the XML string. This header is used by the ReadXMLFile method or XMLString property of the control to identify the type of data and load it appropriately.
NOTE: When data for the entire control is read, all collection data for the control is cleared in anticipation of the new data. When collection-specific XML data is read, the collection is not cleared, rather the data is appended to the current data in the collection. It is the responsibility of the programmer to clear the collection before accepting the XML data if required.