DataSets and XML – A Perfect Combination

What are DataSets? A DataSet is in effect an in-memory representation of cached, disconnected data that is available as a as a collection of tables, relationships, constraints, etc. In other words, a DataSet is actually an in-memory representation of the entire database along with its tables and relationships. The DataSet class is contained in the System.Data namespace in ADO.NET. The DataSet class has the ability to represent itself as XML upon request or when you pass it through the tiers or components of an application. The primary advantage in using DataSets in applications is its disconnected approach that enables data to be transferred across application boundaries. The primary disadvantage of using DataSets however that is it consumes large amount of memory that is particularly a nightmare if your DataSet contains high volume of data. Hence, it becomes detrimental to the application’s performance when the DataSet contains large amount of data due to excessive consumption of memory.

DataSet and XML – A perfect match

Before we delve deep any further, let us have a recap of XML. What is XML and why is it so useful? Extensible Markup Language (XML) is a simple, platform independent, flexible meta-markup language that provides a format for storing structured data and is great for efficient exchange of data across the internet. XML has rapidly gained wide popularity and the enterprise applications the world over are using XML as the primary format for data exchange across the globe. The salient features of this language are:–
  • Robust
  • Support for UNICODE
  • Hierarchical structure
  • Platform Independent
  • Present in human readable format
  • Can support even complex data structures
Now that we have had a quick tour of XML, let us discuss the support for XML provided by the DataSet class in ADO.NET. The DataSet class in ADO.NET contains a lot of methods that provide XML support. The following are some of the most important methods of this class:–
  • The ReadXml Method
  • The ReadXmlSchema Method
  • The GetXml Method
  • The GetXmlSchema Method
  • The WriteXml Method
  • The WriteXmlSchema Method
While the ReadXML, GetXML and WriteXML methods deal with the data as XML representation devoid of any schema, the ReadXMlSchema, WriteXMLSchema and the GetXMLSchema methods represent the schema only. These methods would become much clear as we move on to the next section where working (for CRUD operations) with DataSet instances and XML has been illustrated.
Continues…

Leave a comment

Your email address will not be published.