XML Serialization Sample

Sample Overview

This sample illustrates using the XSD utility and XML serialization to create in-memory objects that have been deserialized from XML files.

The sample consists of two elements:

  1. The purchaseorder XSD file which will be built into the purchaseorder.dll assembly by means of the XSD tool.
  2. The xmlserialize.cs source code, which will use the generated purchaseorder assembly to create a type definition used to deserialize an XML file into an object instance. The deserialized object instance will be modified and then serialized back out to a different XML file with the modifications.

Sample Source and Build Output Locations

The sample source is found in two directories under sscli\samples\howto\xmlserialization:

The build output location is %TARGETCOMPLUS%\samples\howto\xmlserialization. 

The output files are:

The input file, inputdata.xml, is also copied to the %TARGETCOMPLUS%\samples\howto\xmlserialization directory.

The sample displays the status of deserializing the object from the XML file and reserializing it. After the sample runs, a new file named purchaseorder_serialized.xml will have been created in the %TARGETCOMPLUS%\samples\howto\xmlserialization directory. This file contains the modified content of the deserialized object instance.

Building the Sample

All samples are built from the buildall script. 

You can also build all the samples by switching to the root of the sample directory, sscli\samples, and typing build -c.

You can build this specific sample by switching to the sample directory and typing build -c.

Running the Sample

These steps require that the Shared Source CLI (SSCLI) be already built and functional.

  1. Run env.bat or source the env.csh or env.sh script files, depending on your platform.
  2. Switch to the %TARGETCOMPLUS%\samples\howto\xmlserialization directory.
  3. Type the following command:

    clix xmlserialize.exe


Copyright (c) 2002 Microsoft Corporation. All rights reserved.