Writing a DataSet to XML without Schema InformationThe 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.
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() |