Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 1140

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Xml Import-Export In .NET</title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Xml Import-Export In .NET</h1><script>
//We attach this function to a browser object as a variable so that if multiple of these blocks are
//present on the same page, then they will simply over-write eachother with the same function instead
//of generating a naming collision.
window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){
	var sContent = document.getElementById(sID).innerText;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", sContent);
	}
	else
	{
		alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions.");
	}
}
</script>


<p><font color="#990000">This topic applies to .NET version only</font> <br></p>

<p>One of the most widely used platform independent formats of data exchange today is xml.</p>

<p>Db4o
does not provide any specific API to be used for XML import/export, but
with the variety of XML serialization tools available for Java and .NET
(freeware and licensed) this is not really necessary. </p>

<p>All that you need to export your database/query results is:</p>

<ol>
<li>Retrieve objects from the database.</li>

<li>Serialize them in XML format (using language, or external tools, or your own serializing software).</li>

<li>Save XML stream (to a disc location, into memory, into another database).</li>
</ol>

<p>Import process is just the reverse:</p>

<ol>
<li>Read XML stream</li>

<li>Create an objects from XML</li>

<li>Save objects to db4o</li>
</ol>

<p>Let's go through a simple example. We will use .NET XmlSerializer. (You can use 
any other XML serialization tool, which is able to serialize/deserialize 
classes).</p>

<p>First, let's prepare a database:</p>

<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SerializeExample.cs: <span class="fscMemberName">SetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> SetObjects()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_35_348_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      File.Delete(Db4oFileName);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_139_305_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Car car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Rubens Barrichello</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">));
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Set(car);
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">));
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Set(car);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_SetObjects_1162_62_322_344_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SerializeExample.vb: <span class="fscMemberName">SetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub SetObjects()</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_SetObjects_1288_62_15_455_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> SetObjects()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            File.Delete(Db4oFileName)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Rubens Barrichello</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">))
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(car)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">))
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(car)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>We will save the database to XML file "formula1.xml":</p>

<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SerializeExample.cs: <span class="fscMemberName">ExportToXml</span></span></div><div class="fscCode"><pre ID="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> ExportToXml()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_36_552_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      XmlSerializer carSerializer </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> XmlSerializer(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car[]));
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      StreamWriter xmlWriter </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> StreamWriter(XmlFileName);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_236_511_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Car[] cars </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car[result.Size()];
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">int</span><span style="color: #000000;"> i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;">&lt;</span><span style="color: #000000;"> result.Size(); i</span><span style="color: #000000;">++</span><span style="color: #000000;">)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_372_437_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          Car car </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Car)result[i];
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          cars.SetValue(car,i);
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>        }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        carSerializer.Serialize(xmlWriter, cars);
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        xmlWriter.Close();
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;">
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ExportToXml_1478_63_526_548_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SerializeExample.vb: <span class="fscMemberName">ExportToXml</span></span></div><div class="fscCode"><pre ID="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub ExportToXml()</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ExportToXml_1605_63_15_794_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> ExportToXml()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> carSerializer </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> XmlSerializer </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> XmlSerializer(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car()))
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> xmlWriter </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> StreamWriter </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> StreamWriter(XmlFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> cars() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(result.Size()) {}
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> i </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;">
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">For</span><span style="color: #000000;"> i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">To</span><span style="color: #000000;"> result.Size() </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Step</span><span style="color: #000000;"> i </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(result(i), Car)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    cars.SetValue(car, i)
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Next</span><span style="color: #000000;">
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                carSerializer.Serialize(xmlWriter, cars)
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                xmlWriter.Close()
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>After the method executes all car objects from the database will be stored in 
the export file as an array. Note that child objects (Pilot) are stored as well 
without any additional settings. You can check the created XML file to see how 
it looks like.</p>

<p>Now we can clean the database and try to recreate it from the 
XML file:</p>

<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SerializeExample.cs: <span class="fscMemberName">ImportFromXml</span></span></div><div class="fscCode"><pre ID="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> ImportFromXml()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_38_730_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      File.Delete(Db4oFileName);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      XmlSerializer carSerializer </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> XmlSerializer(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car[]));
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      FileStream xmlFileStream </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileStream(XmlFileName, FileMode.Open);
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      Car[] cars </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Car[])carSerializer.Deserialize(xmlFileStream);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db;
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (Car car </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> cars)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_332_496_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_392_448_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          Car newCar </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Car)car;
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          db.Set(newCar);
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>        }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_467_491_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          db.Close();
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>        }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_552_687_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot));
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingCS.ZipsSerializeExample.Cs_SerializeExample.Cs_ImportFromXml_2084_65_704_726_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SerializeExample.vb: <span class="fscMemberName">ImportFromXml</span></span></div><div class="fscCode"><pre ID="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Open_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Closed_Text').style.display='inline';"/><img id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Closed_Text').style.display='none'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Open_Image').style.display='inline'; document.getElementById('ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub ImportFromXml()</span><span id="ResourcesReferencePlatform_Specific_IssuesserializingVB.ZipsSerializeExample.Vb_SerializeExample.Vb_ImportFromXml_2213_65_15_1026_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> ImportFromXml()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            File.Delete(Db4oFileName)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> carSerializer </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> XmlSerializer </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> XmlSerializer(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car()))
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> xmlFileStream </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> FileStream </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> FileStream(XmlFileName, FileMode.Open)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> cars() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(carSerializer.Deserialize(xmlFileStream), Car())
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">For</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Each</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">In</span><span style="color: #000000;"> cars
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> newCar </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(car, Car)
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    db.Set(newCar)
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    db.Close()
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Next</span><span style="color: #000000;">
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot))
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>Easy,
isn't it? Obviously there is much more about XML serialization:
renaming fields, storing collections, selective persistence etc. You
should be able to find detailed description together with the
serialization library, which you will use.</p></div>
    </div>
    <div id="footer">
					This revision (5) was last Modified 2007-12-26T14:59:36 by Tetyana.
				</div>
  </body>
</html>