The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
XmlElementAttributes::Add Method (XmlElementAttribute^)
.NET Framework (current version)
Adds an XmlElementAttribute to the collection.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- attribute
-
Type:
System.Xml.Serialization::XmlElementAttribute^
The XmlElementAttribute to add.
The following example creates two XmlElementAttribute objects and calls the Add method to add them to an XmlElementAttributes. The example then adds the XmlElementAttributes to an XmlAttributeOverrides, which is used to create an XmlSerializer that can serialize an instance of the Transportation class.
public: XmlSerializer^ CreateOverrider() { // Create XmlAttributes and XmlAttributeOverrides instances. XmlAttributes^ attrs = gcnew XmlAttributes; XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; /* Create an XmlElementAttributes to override the Vehicles property. */ XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); // Add the XmlElementAttribute to the collection. attrs->XmlElements->Add( xElement1 ); /* Create a second XmlElementAttribute, and add to the collection. */ XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); attrs->XmlElements->Add( xElement2 ); /* Add the XmlAttributes to the XmlAttributeOverrides, specifying the member to override. */ xOver->Add( Transportation::typeid, "Vehicles", attrs ); // Create the XmlSerializer, and return it. XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); return xSer; }
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: