Saturday, May 23, 2009

Look at Difference between XmlDocument and XmlDataDocument

The DataSet class in ADO.NET provides the developer with a relational view of data. Using the DataSet, data are stored as tables, which allows for easy retrievals using SQL statements. However, there are times when you need a hierarchical representation of the data, allowing you to perform quick searches using, say, XPath queries. You may also need to transform a set of data into another format using XSLT. In such cases, the .NET framework provides you with the XmlDocument class for this purpose.

However, the DataSet and XmlDocument classes only allow one way of data representation--either you have a relational or hierarchical view, but not both. It is with this purpose that the XmlDataDocument class was designed. The XmlDataDocument class is derived from the XmlDocument class, providing a hierarchical view of data as well as a relational view by binding it to a DataSet. Best of all, it automatically synchronizes the data changes made by either one of the two views. XmlDataDocument provides the best of both worlds--it can manipulate the data using the familiarDataSet, as well as support the various services in the XML classes (such as DOM, XPath, and XSLT). In this case, I will show you how you how to use the XmlDataDocument class

XmlDataDocument Allows structured data to be stored, retrieved, and manipulated through a relational DataSetThis class extends XmlDocument. It enables you to load either relational data or XML data and manipulate that data using the World Wide Web Consortium (W3C) Document Object Model (DOM). The DOM presents data as a hierarchy of node objects. Because XmlDataDocument implements the IXPathNavigable interface, it can also be used as the source document for the XslTransform class.

XmlDataDocument has a close affiliation with the DataSet class, which provides a relational view of the loaded XML data. Any changes made to theXmlDataDocument are reflected in the DataSet and vice versa.
 
And Now let's go through the difference between XmlDocument and XmlDataDocument 

  • XML Document
  1. The XmlDocument, XmlNode and other classes implement the W3C Document Object Model Level 1 Core and the Core DOM Level 2 specifications. 
  2. The XmlDocument is an in-memory (cache) tree representation of an XML document. 
  3. There are different node types specializing from XmlNode to enable you to manipulate the XML document. 
  4. You can get faster, non-cached, forward-only stream access to XML using the XmlTextReader and XmlTextWriter classes
  • XML DataDocument
  1. The XmlDataDocument class provides an in memory cache for XML data. 
  2. The XmlDataDocument extends the XmlDocument class. XmlDataDocument can be used anywhere the XmlDocument class is used. 
  3. There is a close association between the XmlDataDocument and the DataSet classes. In fact, you can regard the XmlDataDocument as a DataSet-aware XmlDocument. 

4 comments:

  1. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    python Online training in chennai
    python Online training in bangalore
    python interview question and answers

    ReplyDelete
  2. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
    AWS training in sholinganallur
    AWS training in Tambaram
    AWS training in Velachery

    ReplyDelete