Export (0) Print
Expand All

XmlSerializerNamespaces Class

Contains the XML namespaces and prefixes that the XmlSerializer uses to generate qualified names in an XML-document instance.

System.Object
  System.Xml.Serialization.XmlSerializerNamespaces

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

public class XmlSerializerNamespaces

The XmlSerializerNamespaces type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlSerializerNamespaces()Initializes a new instance of the XmlSerializerNamespaces class.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlSerializerNamespaces(XmlQualifiedName[])Initializes a new instance of the XmlSerializerNamespaces class.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlSerializerNamespaces(XmlSerializerNamespaces)Infrastructure. Initializes a new instance of the XmlSerializerNamespaces class, using the specified instance of XmlSerializerNamespaces that contains the collection of prefix and namespace pairs.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360CountGets the number of prefix and namespace pairs in the collection.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360AddAdds a prefix and namespace pair to an XmlSerializerNamespaces object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToArrayGets the array of prefix and namespace pairs in an XmlSerializerNamespaces object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The XmlSerializerNamespaces contains a collection of XML namespaces, each with an associated prefix. The XmlSerializer uses an instance of the XmlSerializerNamespaces class to create qualified names in an XML document.

XML namespaces contained by the XmlSerializerNamespaces must conform to the www.w3.org specification, Namespaces in XML.

XML namespaces provide a way to qualify the names of XML elements and attributes in XML documents. A qualified name consists of a prefix and a local name, separated by a colon. The prefix functions only as a placeholder; it is mapped to a URI that specifies a namespace. The combination of the universally-managed URI namespace and the local name produces a name that is guaranteed to be universally unique.

To create qualified names in an XML document:

  1. Create an XmlSerializerNamespaces instance.

  2. Add each prefix and namespace pair that you want to the instance.

  3. Apply the appropriate .NET attribute to each property or class that the XmlSerializer serializes into an XML document. The available attributes are:

  1. Set the Namespace property of each attribute to one of the namespace values from the XmlSerializerNamespaces object.

  2. Pass the XmlSerializerNamespaces to the Serialize method of the XmlSerializer.

NoteNote:

The creation of an empty namespace and prefix pair is not supported. That is, you cannot create a pair using the following code.

XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); 
ns.Add("", "");

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft