Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlSerializer.Serialize Method (XmlWriter, Object, XmlSerializerNamespaces, String, String)

Note: This method is new in the .NET Framework version 2.0.

Serializes the specified Object and writes the XML document to a file using the specified XmlWriter, XML namespaces, and encoding.

Namespace: System.Xml.Serialization
Assembly: System.Xml (in system.xml.dll)

public void Serialize (
	XmlWriter xmlWriter,
	Object o,
	XmlSerializerNamespaces namespaces,
	string encodingStyle,
	string id
public void Serialize (
	XmlWriter xmlWriter, 
	Object o, 
	XmlSerializerNamespaces namespaces, 
	String encodingStyle, 
	String id
public function Serialize (
	xmlWriter : XmlWriter, 
	o : Object, 
	namespaces : XmlSerializerNamespaces, 
	encodingStyle : String, 
	id : String



The XmlWriter used to write the XML document.


The object to serialize.


An instance of the XmlSerializaerNamespaces that contains namespaces and prefixes to use.


The encoding used in the document.


For SOAP encoded messages, the base used to generate id attributes.

The id parameter supplies the base string used to create SOAP ids. By default, these are "id1", "id2" and so on. But if the parameter is set to "myBase" the generated values are "myBaseid1", "myBaseid2" and so on. This functionality is used to create unique id values across the whole SOAP message.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft