System.Xml.Serialization Namespace

System.Xml.Serialization 命名空间包含用于将对象序列化为 XML 格式文档或流的类。 The System.Xml.Serialization namespace contains classes that are used to serialize objects into XML format documents or streams.

CodeExporter

表示一个类,该类可从数据结构的 XML 表示形式生成代理代码。Represents a class that can generate proxy code from an XML representation of a data structure.

CodeIdentifier

提供一些静态方法,用于将输入文本转换为代码实体的名称。Provides static methods to convert input text into names for code entities.

CodeIdentifiers

维护相关代码实体或类型映射的一组名称,这些名称是 .NET Framework 的 XML 序列化基础结构生成的。Maintains a group of names for related code entities or type mappings that are generated by the .NET Framework's XML serialization infrastructure.

ImportContext

描述特定上下文,架构集在该上下文中绑定到 .NET Framework 代码实体。Describes the context in which a set of schema is bound to .NET Framework code entities.

SchemaImporter

描述架构导入程序。Describes a schema importer.

SoapAttributeAttribute

指定 XmlSerializer 必须将类成员序列化为编码的 SOAP 特性。Specifies that the XmlSerializer must serialize the class member as an encoded SOAP attribute.

SoapAttributeOverrides

允许您在使用 XmlSerializer 将对象序列化或反序列化为编码的 SOAP 时重写应用于属性、字段和类的特性。Allows you to override attributes applied to properties, fields, and classes when you use an XmlSerializer to serialize or deserialize an object as encoded SOAP.

SoapAttributes

表示特性对象的集合,这些对象控制 XmlSerializer 如何序列化和反序列化 SOAP 方法。Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes SOAP methods.

SoapCodeExporter

从 WSDL 文档中定义的 SOAP 编码的消息部分的内部类型映射信息生成类型和特性声明。Generates types and attribute declarations from internal type mapping information for SOAP-encoded message parts defined in a WSDL document.

SoapElementAttribute

指定公共成员值由 XmlSerializer 序列化为经过编码的 SOAP XML 元素。Specifies that the public member value be serialized by the XmlSerializer as an encoded SOAP XML element.

SoapEnumAttribute

控制 XmlSerializer 如何序列化枚举成员。Controls how the XmlSerializer serializes an enumeration member.

SoapIgnoreAttribute

指示 XmlSerializer 不序列化公共字段或公共读/写属性值。Instructs the XmlSerializer not to serialize the public field or public read/write property value.

SoapIncludeAttribute

允许 XmlSerializer 在将对象序列化或反序列化为编码的 SOAP XML 时识别类型。Allows the XmlSerializer to recognize a type when it serializes or deserializes an object as encoded SOAP XML.

SoapReflectionImporter

生成从 .NET Framework 类型或 Web 服务方法信息到 SOAP 编码消息的映射。Generates mappings to SOAP-encoded messages from .NET Framework types or Web service method information.

SoapSchemaExporter

使用 .NET Framework 类型的 XML 架构数据类型定义填充 XmlSchema 对象,该 .NET Framework 类型是用 SOAP 编码串行化的。Populates XmlSchema objects with XML Schema data type definitions for .NET Framework types that are serialized using SOAP encoding.

SoapSchemaImporter

在 .NET Framework 内使用来为 WSDL 文档中 SOAP 编码的消息部分生成到 .NET Framework 类型的内部映射。Used within the .NET Framework to generate internal mappings to .NET Framework types for SOAP-encoded message parts in a WSDL document.

SoapSchemaMember

表示 WSDL 文档中 XSD <part> 元素的特定属性,用于从文档中生成类。Represents certain attributes of a XSD <part> element in a WSDL document for generating classes from the document.

SoapTypeAttribute

将类实例序列化为 SOAP 编码的 XML 时,控制 XmlSerializer 生成的架构。Controls the schema generated by the XmlSerializer when a class instance is serialized as SOAP encoded XML.

UnreferencedObjectEventArgs

在反序列化期间,为在编码的 SOAP XML 流中找到的已知的(但未引用的)对象提供数据。Provides data for the known, but unreferenced, object found in an encoded SOAP XML stream during deserialization.

XmlAnyAttributeAttribute

指定成员(返回 XmlAttribute 对象的数组的字段)可以包含任何 XML 特性。Specifies that the member (a field that returns an array of XmlAttribute objects) can contain any XML attributes.

XmlAnyElementAttribute

指定成员(返回 XmlElementXmlNode 对象的数组的字段)可以包含对象,该对象表示在序列化或反序列化的对象中没有相应成员的所有 XML 元素。Specifies that the member (a field that returns an array of XmlElement or XmlNode objects) contains objects that represent any XML element that has no corresponding member in the object being serialized or deserialized.

XmlAnyElementAttributes

表示 XmlAnyElementAttribute 对象集合。Represents a collection of XmlAnyElementAttribute objects.

XmlArrayAttribute

指定 XmlSerializer 必须将特定的类成员序列化为 XML 元素的数组。Specifies that the XmlSerializer must serialize a particular class member as an array of XML elements.

XmlArrayItemAttribute

表示指定 XmlSerializer 可以放置在序列化数组中的派生类型的特性。Represents an attribute that specifies the derived types that the XmlSerializer can place in a serialized array.

XmlArrayItemAttributes

表示 XmlArrayItemAttribute 对象集合。Represents a collection of XmlArrayItemAttribute objects.

XmlAttributeAttribute

指定 XmlSerializer 必须将类成员序列化为 XML 属性。Specifies that the XmlSerializer must serialize the class member as an XML attribute.

XmlAttributeEventArgs

UnknownAttribute 事件提供数据。Provides data for the UnknownAttribute event.

XmlAttributeOverrides

允许在使用 XmlSerializer 串行化或反序列化对象时替代属性、字段和类特性。Allows you to override property, field, and class attributes when you use the XmlSerializer to serialize or deserialize an object.

XmlAttributes

表示控制 XmlSerializer 串行化和反序列化对象方式的属性对象的集合。Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes an object.

XmlChoiceIdentifierAttribute

指定可以通过使用枚举来进一步检测成员。Specifies that the member can be further detected by using an enumeration.

XmlCodeExporter

从 XML 架构元素声明的内部类型映射信息生成类型和特性声明。Generates types and attribute declarations from internal type mapping information for XML schema element declarations.

XmlElementAttribute

指示公共字段或属性在 XmlSerializer 序列化或反序列化包含它们的对象时表示 XML 元素。Indicates that a public field or property represents an XML element when the XmlSerializer serializes or deserializes the object that contains it.

XmlElementAttributes

表示 XmlElementAttribute 对象的集合,该对象由 XmlSerializer 用来重写序列化类的默认方式。Represents a collection of XmlElementAttribute objects used by the XmlSerializer to override the default way it serializes a class.

XmlElementEventArgs

UnknownElement 事件提供数据。Provides data for the UnknownElement event.

XmlEnumAttribute

控制 XmlSerializer 如何序列化枚举成员。Controls how the XmlSerializer serializes an enumeration member.

XmlIgnoreAttribute

指示 Serialize(TextWriter, Object)XmlSerializer 方法不序列化公共字段或公共读/写属性值。Instructs the Serialize(TextWriter, Object) method of the XmlSerializer not to serialize the public field or public read/write property value.

XmlIncludeAttribute

允许 XmlSerializer 在它序列化或反序列化对象时识别类型。Allows the XmlSerializer to recognize a type when it serializes or deserializes an object.

XmlMapping

支持 .NET Framework 类型和 XML 架构数据类型之间的映射。Supports mappings between .NET Framework types and XML Schema data types.

XmlMemberMapping

将 .NET Framework Web 服务方法中的代码实体映射到 Web 服务描述语言 (WSDL) 消息中的元素。Maps a code entity in a .NET Framework Web service method to an element in a Web Services Description Language (WSDL) message.

XmlMembersMapping

提供 .NET Framework Web 服务方法与为 SOAP Web 服务定义的 Web 服务描述语言 (WSDL) 消息之间的映射。Provides mappings between .NET Framework Web service methods and Web Services Description Language (WSDL) messages that are defined for SOAP Web services.

XmlNamespaceDeclarationsAttribute

指定目标属性、参数、返回值或类成员包含与 XML 文档中所用命名空间关联的前缀。Specifies that the target property, parameter, return value, or class member contains prefixes associated with namespaces that are used within an XML document.

XmlNodeEventArgs

UnknownNode 事件提供数据。Provides data for the UnknownNode event.

XmlReflectionImporter

为 .NET Framework 类型或 Web 服务方法信息生成到 XML 架构元素声明(包括 Web 服务描述语言 (WSDL) 文档中的文本 XML 架构定义 (XSD) 消息部分)的映射。Generates mappings to XML schema element declarations, including literal XML Schema Definition (XSD) message parts in a Web Services Description Language (WSDL) document, for .NET Framework types or Web service method information.

XmlReflectionMember

提供 .NET Framework Web 服务方法中的代码实体与为 SOAP Web 服务定义的 Web 服务描述语言 (WSDL) 消息的内容之间的映射。Provides mappings between code entities in .NET Framework Web service methods and the content of Web Services Description Language (WSDL) messages that are defined for SOAP Web services.

XmlRootAttribute

控制视为 XML 根元素的属性目标的 XML 序列化。Controls XML serialization of the attribute target as an XML root element.

XmlSchemaEnumerator

启用 XmlSchema 对象的集合上的迭代。Enables iteration over a collection of XmlSchema objects.

XmlSchemaExporter

使用类型映射对象中的 XML 架构元素声明填充 XmlSchema 对象。Populates XmlSchema objects with XML schema element declarations that are found in type mapping objects.

XmlSchemaImporter

为 XML 架构元素声明(包括 WSDL 文档中的文本 XSD 消息部分)生成到 .NET Framework 类型的内部映射。Generates internal mappings to .NET Framework types for XML schema element declarations, including literal XSD message parts in a WSDL document.

XmlSchemaProviderAttribute

应用于某个类型时,存储返回 XML 架构的该类型静态方法的名称和控制该类型序列化的 XmlQualifiedName(对于匿名类型,为 XmlSchemaType)。When applied to a type, stores the name of a static method of the type that returns an XML schema and a XmlQualifiedName (or XmlSchemaType for anonymous types) that controls the serialization of the type.

XmlSchemas

表示 XML 架构的集合。Represents the collection of XML schemas.

XmlSerializationGeneratedCode

一个抽象类,该类是 XmlSerializationReaderXmlSerializationWriter 以及包含这两种类型的通用方法的那些类型的基类。An abstract class that is the base class for XmlSerializationReader and XmlSerializationWriter and that contains methods common to both of these types.

XmlSerializationReader

控制由 XmlSerializer 类执行的反序列化。Controls deserialization by the XmlSerializer class.

XmlSerializationReader.CollectionFixup

保存 XmlSerializationCollectionFixupCallback 委托实例和方法的输入;还提供方法的参数。Holds an XmlSerializationCollectionFixupCallback delegate instance, plus the method's inputs; also supplies the method's parameters.

XmlSerializationReader.Fixup

保存 XmlSerializationFixupCallback 委托实例,以及该方法的输入;也作为该方法的参数使用。Holds an XmlSerializationFixupCallback delegate instance, plus the method's inputs; also serves as the parameter for the method.

XmlSerializationWriter

表示抽象类,用于控制由 XmlSerializer 类执行的序列化。Represents an abstract class used for controlling serialization by the XmlSerializer class.

XmlSerializer

将对象序列化到 XML 文档中和从 XML 文档中反序列化对象。Serializes and deserializes objects into and from XML documents. XmlSerializer 使您得以控制如何将对象编码到 XML 中。The XmlSerializer enables you to control how objects are encoded into XML.

XmlSerializerAssemblyAttribute

应用于 Web 服务客户端代理,可用来指定包含自定义序列化程序的程序集。Applied to a Web service client proxy, enables you to specify an assembly that contains custom-made serializers.

XmlSerializerFactory

创建 XmlSerializer 的类型化版本,以使序列化更为有效。Creates typed versions of the XmlSerializer for more efficient serialization.

XmlSerializerImplementation

为预生成的类型化序列化程序定义读取器、编写器和方法。Defines the reader, writer, and methods for pre-generated, typed serializers.

XmlSerializerNamespaces

包含 XmlSerializer 用于在 XML 文档实例中生成限定名的 XML 命名空间和前缀。Contains the XML namespaces and prefixes that the XmlSerializer uses to generate qualified names in an XML-document instance.

XmlSerializerVersionAttribute

表示代码是由序列化基础结构生成的,向程序集应用此特性时,可重复使用以提高性能。Signifies that the code was generated by the serialization infrastructure and can be reused for increased performance, when this attribute is applied to an assembly.

XmlTextAttribute

当串行化或反序列化包含该成员的类时,向 XmlSerializer 指示应将该成员作为 XML 文本处理。Indicates to the XmlSerializer that the member must be treated as XML text when the class that contains it is serialized or deserialized.

XmlTypeAttribute

控制当属性目标由 XmlSerializer 序列化时生成的 XML 架构。Controls the XML schema that is generated when the attribute target is serialized by the XmlSerializer.

XmlTypeMapping

包含从一种类型到另一种类型的映射。Contains a mapping of one type to another.

结构

XmlDeserializationEvents

包含可用于将事件委托传递给 Deserialize 的线程安全的 XmlSerializer 方法的字段。Contains fields that can be used to pass event delegates to a thread-safe Deserialize method of the XmlSerializer.

接口

IXmlSerializable

提供面向 XML 序列化和反序列化的自定义格式。Provides custom formatting for XML serialization and deserialization.

IXmlTextParser

建立一个 Normalized 属性供 .NET Framework 基础结构使用。Establishes a Normalized property for use by the .NET Framework infrastructure.

枚举

CodeGenerationOptions

指定在生成用于 XML Web services 的 .NET 类型时使用的各种选项。Specifies various options to use when generating .NET types for use with an XML Web Service.

XmlMappingAccess

指定映射是读取、写入,还是既读取又写入。Specifies whether a mapping is read, write, or both.

委托

UnreferencedObjectEventHandler

表示处理 XmlSerializerUnreferencedObject 事件的方法。Represents the method that handles the UnreferencedObject event of an XmlSerializer.

XmlAttributeEventHandler

表示处理 UnknownAttribute 的方法Represents the method that handles the UnknownAttribute

XmlElementEventHandler

表示处理 XmlSerializerUnknownElement 事件的方法。Represents the method that handles the UnknownElement event of an XmlSerializer.

XmlNodeEventHandler

表示处理 XmlSerializerUnknownNode 事件的方法。Represents the method that handles the UnknownNode event of an XmlSerializer.

XmlSerializationCollectionFixupCallback

XmlSerializer 类用于对映射到集合或枚举的 SOAP 编码的 XML 数据类型进行反序列化的委托。Delegate used by the XmlSerializer class for deserialization of SOAP-encoded XML data types that map to collections or enumerations.

XmlSerializationFixupCallback

XmlSerializer 类用来反序列化 SOAP 编码的 XML 数据的委托。Delegate used by the XmlSerializer class for deserialization of SOAP-encoded XML data.

XmlSerializationReadCallback

XmlSerializer 类为了对 SOAP 编码的非根 XML 数据的类型进行反序列化而使用的委托。Delegate used by the XmlSerializer class for deserialization of types from SOAP-encoded, non-root XML data.

XmlSerializationWriteCallback

XmlSerializer 类为了对 SOAP 编码的非根 XML 数据的类型进行序列化而使用的委托。Delegate that is used by the XmlSerializer class for serialization of types from SOAP-encoded, non-root XML data.

注解

命名空间中的中心类是XmlSerializer类。The central class in the namespace is the XmlSerializer class. 若要使用此类,使用XmlSerializer构造函数来创建使用对象的类型进行序列化的类的实例。To use this class, use the XmlSerializer constructor to create an instance of the class using the type of the object to serialize. 一次XmlSerializer是创建,创建要序列化的对象的实例。Once an XmlSerializer is created, create an instance of the object to serialize. 您还必须创建的对象,若要将文件写入的文档或流,如StreamTextWriter,或XmlWriterYou must also create an object to write the file to a document or stream, such as a Stream, TextWriter, or XmlWriter. 然后,可以调用Serialize方法将对象转换为 XML 文档。You can then call the Serialize method to convert the object into an XML document.

若要反序列化的 XML 文档中的对象,创建适合要读取的文档或流 (再次StreamTextWriter,或XmlWriter)。To deserialize an object from an XML document, create a suitable object to read the document or stream (again, a Stream, TextWriter, or XmlWriter). 调用Deserialize方法,同时强制转换为原始对象 (即进行序列化) 的类型生成的对象。Invoke the Deserialize method while casting the resulting object to the type of the original object (that was serialized).

若要进一步控制的序列化,System.Xml.Serialization命名空间包含多个Attribute可以应用于类的成员的类。To further control the serialization, the System.Xml.Serialization namespace contains several Attribute classes that can be applied to members of a class. 例如,如果类包含将序列化为 XML 元素的成员,则可以应用XmlElementAttribute属性成员。For example, if a class contains a member that will be serialized as an XML element, you can apply the XmlElementAttribute attribute to the member. 在应用特性时,可以指定详细信息,例如实际的 XML 元素名称使用ElementName属性。When applying the attribute, you can specify details such as the actual XML element name using the ElementName property. 所有属性的完整列表,请参阅XmlSerializer类概述。For a complete list of all the attributes, see the XmlSerializer class overview.