Writing a DataSet to XML without Schema Information


Writing a DataSet to XML without Schema Information

The process of loading schema information into a DataSet is computationally intensive and time consuming, especially on a device. An efficient way to deal with a DataSet is to load its schema just once when you first instantiate it. You can store the schema information in a separate XML file. Use ReadXmlSchema() to do this.

All subsequent writing of the actual tables can be written without the schema included. Since you will load this data back into another DataSet that already has a schema loaded, you can save yourself the time of having to load schema repeatedly. You can also save space and network bandwidth by writing the XML data without schema, if you know that everyone who will consume the XML already knows the schema.

READING SCHEMA IS EXPENSIVE

In situations where the amount of data in a DataSet is relatively small, but the schema is complex, reading the schema takes a significant portion of the time that it takes to read an XML document into the DataSet .


To write a DataSet to XML without writing schema information, call DataSet.WriteXml(XmlWriter, XmlWriteMode) , and pass XmlWriteMode.IgnoreSchema as an argument. For example:

 
 C# l_XmlTextWriter = new System.Xml.XmlTextWriter(new System.IO.StreamWriter         ("\NO_SCHEMA_DS.xml")); l_DataSet.WriteXml(l_XmlTextWriter, XmlWriteMode.IgnoreSchema); l_XmlTextWriter.Close(); VB l_XmlTextWriter = new System.Xml.XmlTextWriter(new System.IO.StreamWriter         ("\NO_SCHEMA_DS.xml")) l_DataSet.WriteXml(l_XmlTextWriter, XmlWriteMode.IgnoreSchema) l_XmlTextWriter.Close() 


Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net