XmlArrayItemAttribute::ElementName Property
.NET Framework (current version)
Gets or sets the name of the generated XML element.
Assembly: System.Xml (in System.Xml.dll)
Property Value
Type: System::String^The name of the generated XML element. The default is the member identifier.
Specify an ElementName if you want the name of the generated XML element to differ from the member's identifier.
You can set the same ElementName value to more than one class member if the generated XML document uses XML namespaces to distinguish between identically named members. For details about how to use namespaces and prefixed names in the XML document, see the XmlSerializerNamespaces class.
The following example sets the ElementName property for the Vehicle and Car class--thereby changing the names of XML elements that the XmlSerializer generates for those classes.
// By default, this class results in XML elements named "Vehicle". public ref class Vehicle { public: String^ id; }; // By default, this class results in XML elements named "Car". public ref class Car: public Vehicle { public: String^ Maker; }; public ref class Transportation { public: /* Specifies acceptable types and the ElementName generated for each object type. */ [XmlArray("Vehicles")] [XmlArrayItem(Vehicle::typeid,ElementName="Transport"), XmlArrayItem(Car::typeid,ElementName="Automobile")] array<Vehicle^>^MyVehicles; };
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: