XmlTypeAttribute.TypeName Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the name of the XML type.

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

public string TypeName { get; set; }

Property Value

Type: System.String

The name of the XML type.

Apply the XmlTypeAttribute to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the XmlTypeAttribute class, compile your application as an executable or DLL, and pass the resulting file to the XML Schema Definition Tool (Xsd.exe). The tool writes the schema, including the type definition.

The following example applies the XmlTypeAttribute to the Person and Job classes. If you compile the class and pass the resulting executable file to the XML Schema Definition tool, the schema is displayed in the Output section.

public class Group {
   public Person[]Staff;
}

[XmlType(TypeName = "Employee",
         Namespace = "http://www.cpandl.com")]
public class Person {
   public string PersonName;
   public Job Position;
}

[XmlType(TypeName = "Occupation", 
         Namespace = "http://www.cohowinery.com")]
public class Job {
   public string JobName;
}

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
Return to top
Show: