home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / XML / LoadXmlDocument.aspx < prev    next >
Encoding:
Text File  |  2000-06-10  |  4.5 KB  |  147 lines

  1. <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
  2.  
  3. <!-- #include virtual="/quickstart/howto/doc/xml/header.inc" -->
  4.  
  5. <h4>How Do I...Load XML data into an XmlDataDocument?</h4>
  6.  
  7. <div class="indent" style="width:660">
  8. This sample illustrates how to load XML into the XmlDataDocument class. This class extends the XmlDocument class, allowing structured data to be stored, 
  9. retrieved, and manipulated through a relational DataSet. Also see the <a href="XmlDataSet.aspx">How Do I...Use XML and the DataSet class?</a> topic.
  10. </A></div>
  11.  
  12. <h4>Loading XML data into an XmlDataDocument</h4> 
  13. <Acme:SourceRef
  14. ViewSource="/quickstart/howto/samples/Xml/LoadXmlDocument/LoadXmlDocument.src"
  15. RunSample="/quickstart/howto/samples/Xml/LoadXmlDocument/LoadXmlDocument.aspx" 
  16. Icon = "/quickstart/images/genicon.gif"
  17. Caption="LoadXmlDocument.aspx"
  18. runat="server" />
  19.  
  20. <br clear="left"><br><div class="indent" style="width:660">
  21. The XmlDataDocument class provides an XML API onto loaded XML data by extending the XmlDocument (W3C DOM) class.
  22. (See <a target=content href="DOMInterfaceXmlDocument.aspx">How Do I...Load and use the XmlDocument (W3C DOM)?</a>) and has a close affiliation with the DataSet
  23. class, which provides a relational view onto the loaded XML data.
  24. This combination allows for components to mix XML and relational views of the same underlying data, irrespective of the source of the
  25. data. As detailed in later topics, there are differences between these views. Most notable is that XML data that does not map to the relational view cannot
  26. be accessed via the relational objects (Tables and Rows). It is however, still possible to easily move from a relational row to the equivalent XML element
  27. and hence access this XML data.</div>
  28.  
  29. <br clear="left"><div class="indent" style="width:660">
  30. The XmlDataDocument can be used anywhere an XmlDocument is used; all topics that describe the XmlDocument apply equally to the XmlDataDocument.</div>
  31.  
  32. <br clear="left"><div class="indent" style="width:660">
  33. The following topics are related to this topic.</div>
  34.  
  35. <OL>
  36. <LI><A target=content href="DOMInterfaceXmlDocument.aspx">How Do I...Load and use the XmlDocument (W3C DOM)?</A>
  37. <br clear="left"><br>
  38. <LI><A target=content href="SaveXmlDocument.aspx">How Do I...Save XML with the XmlDocument (W3C DOM)?</A>
  39. <br clear="left"><br>
  40. <LI><A target=content href="StreamAnXmlDocument.aspx">How Do I...Read XML from an XmlDataDocument?</A> 
  41. <br clear="left"><br>
  42. <LI><A target=content href="NavigateXmlDocument.aspx">How Do I...Navigate XML with the XmlNavigator?</A>
  43. <br clear="left"><br>
  44. <LI><A target=content href="EditingXmlDocument.aspx">How Do I...Edit XML with the XmlNavigator?</A> </LI>
  45. <br clear="left"><br>
  46. </OL>
  47.  
  48. <div class="indent" style="width:660">
  49. In this sample we are simply going to load the XmlDataDocument with XML data using the sample file 
  50. <a target="_blank" href="/quickstart/util/srcctrlwin.aspx?path=/quickstart/howto/samples/Xml/LoadXmlDocument/&file=books.xml">books.xml</a>.
  51. The code below illustrates this.
  52. </div>
  53.  
  54. <div class="code">
  55. <xmp>
  56. public class XmlDocumentSample
  57. {
  58.     private const String m_Document = "books.xml";
  59.  
  60.     public static void Main(String[] args)
  61.     {
  62.         XmlDocumentSample myxmldocument = new XmlDocumentSample(args);
  63.     }
  64.  
  65.     public XmlDocumentSample(String[] args)
  66.     {
  67.         try
  68.         {
  69.             // Load the XML from file
  70.             Console.WriteLine ("Loading file {0} ...", m_Document);
  71.  
  72.             XmlDataDocument xmldocument = new XmlDataDocument();
  73.             xmldocument.Load (m_Document);
  74.  
  75.             Console.WriteLine ("XmlDataDocument loaded with XML data successfully ...");
  76.         }
  77.         catch (Exception e)
  78.         {
  79.             Console.WriteLine ("Exception: {0}", e.ToString());
  80.         }
  81.     }
  82. } // End class XmlDocumentSample
  83. </xmp>
  84. </div>
  85.  
  86. <H4>Summary</H4>
  87. <OL>
  88. <LI>The XmlDataDocument class provides an in memory cache for XML data.
  89. <LI>The XmlDataDocument extends the XmlDocument (W3C DOM) class. It can be used anywhere the XmlDocument class is used.
  90. <LI>The XmlDataDocument and the DataSet classes are closely associated, and the XmlDataDocument can be regarded as a DataSet aware XmlDocument. 
  91. <LI>The DataDocumentNavigator class consumes XmlDataDocuments to provide implementations of common XML interfaces for integrated support
  92. with other XML objects.
  93. </LI></OL>
  94.  
  95. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.