﻿<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Write class data to an XML file</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Writes the data from a class to an XML file by using the XmlSerializer class.</Description>
      <Keywords>
      </Keywords>
      <Shortcut>xmlWriteClass</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>System.Xml.dll</Assembly>
          <Version />
          <Url />
        </Reference>
      </References>
      <Imports>
	    <Import>
			<Namespace>System.XML.Serialization</Namespace>
		</Import>
	    <Import>
			<Namespace>System.IO</Namespace>
		</Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>class</ID>
          <Type />
          <ToolTip>Replace with the type name of the class to be serialized.</ToolTip>
          <Default>ArrayList</Default>
        </Literal>
        <Literal>
          <ID>filename</ID>
          <Type />
          <ToolTip>Replace with name of the file to write the data to.</ToolTip>
          <Default>"SerializedData.xml"</Default>
        </Literal>
        <Literal>
          <ID>dataInstance</ID>
          <Type />
          <ToolTip>Replace with the instance of the class containing the data.</ToolTip>
          <Default>dataToWrite</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method decl"><![CDATA[Dim writer As New XMLSerializer(GetType($Class$))
Dim file As New StreamWriter($filename$)
writer.Serialize(file, $dataInstance$)
file.Close()]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>