XmlSerializerNamespaces::Add Method (String^, String^)
.NET Framework (current version)
Adds a prefix and namespace pair to an XmlSerializerNamespaces object.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- prefix
-
Type:
System::String^
The prefix associated with an XML namespace.
- ns
-
Type:
System::String^
An XML namespace.
If you want the XmlSerializer to qualify the element and attribute names in an XML document, you must Add the prefix and namespace pairs to an XmlSerializerNamespaces object.
Any namespaces that you add must conform to the www.w3.org specification Namespaces in XML.
The following example creates an XmlSerializerNamespaces object, and adds three prefix and namespace pairs to it by calling the Add method.
private: XmlSerializerNamespaces^ AddNamespaces() { XmlSerializerNamespaces^ xmlNamespaces = gcnew XmlSerializerNamespaces; // Add three prefix-namespace pairs. xmlNamespaces->Add( "money", "http://www.cpandl.com" ); xmlNamespaces->Add( "books", "http://www.cohowinery.com" ); xmlNamespaces->Add( "software", "http://www.microsoft.com" ); return xmlNamespaces; }
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: