XmlTypeAttribute クラスとは? わかりやすく解説

XmlTypeAttribute クラス

この属性適用され対象が XmlSerializer によってシリアル化されるときに生成される XML スキーマ制御します

名前空間: System.Xml.Serialization
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct
 Or AttributeTargets.Enum Or AttributeTargets.Interface)>
 _
Public Class XmlTypeAttribute
    Inherits Attribute
Dim instance As XmlTypeAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Interface)]
 
public class XmlTypeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Interface)]
 
public ref class XmlTypeAttribute : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Interface)
 */ 
public class XmlTypeAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Interface)
 
public class XmlTypeAttribute extends
 Attribute
解説解説

XmlTypeAttribute は、XmlSerializerオブジェクトシリアル化または逆シリアル化する方法制御する一連の属性1 つです。類似する属性の完全な一覧については、「XML シリアル化制御する属性」を参照してください

XmlTypeAttribute は、クラス構造体列挙体、またはインターフェイス宣言適用できます

XmlTypeAttributeクラス適用しXML 型の名前空間XML 型名、および XML スキーマ ドキュメントにその型を含めかどうか指定しますXmlTypeAttribute クラスプロパティ設定結果確認するには、アプリケーションコンパイルして実行可能ファイルまたは DLL生成し生成されファイルXML スキーマ定義ツール (Xsd.exe) に渡します。このツールは、型定義を含むスキーマ作成します

メモメモ

IncludeInSchema プロパティfalse設定した場合XML スキーマ定義ツール (Xsd.exe) は、スキーマにその型を含めません。既定では、各パブリック クラスに対してXSD ツールcomplexType とその型の要素生成します

属性使用方法については、「属性使用したメタデータ拡張」を参照してください

メモメモ

コードでは、XmlTypeAttribute代わりに XmlType という短い語使用できます

使用例使用例

XmlTypeAttribute適用され2 つクラスの例を次に示します

<XmlType(Namespace := "http://www.cpandl.com",
 _
 TypeName := "GroupMember")> _
Public Class Person
    Public Name As String
End Class

<XmlType(Namespace := "http://www.cohowinery.com",
 _
 TypeName := "GroupAddress")> _ 
Public Class Address
    
    Public Line1 As String
    Public Line2 As String
    Public City As String
    Public State As String
    Public Zip As String
End Class

Public Class Group
    Public Staff() As Person
    Public Manager As Person
    Public Location As Address
End Class

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

[XmlType(Namespace = "http://www.cohowinery.com",
TypeName = "GroupAddress")]
public class Address
{
   public string Line1;
   public string Line2;
   public string City;
   public string State;
   public string Zip;
}

public class Group
{
   public Person[] Staff;
   public Person Manager;
   public Address Location;
}

[XmlType(Namespace="http://www.cpandl.com",
TypeName="GroupMember")]
public ref class Person
{
public:
   String^ Name;
};


[XmlType(Namespace="http://www.cohowinery.com",
TypeName="GroupAddress")]
public ref class Address
{
public:
   String^ Line1;
   String^ Line2;
   String^ City;
   String^ State;
   String^ Zip;
};

public ref class Group
{
public:
   array<Person^>^Staff;
   Person^ Manager;
   Address^ Location;
};

/** @attribute XmlType(Namespace = "http://www.cpandl.com"
,
    TypeName = "GroupMember")
 */
public class Person
{
    public String name;
} //Person

/** @attribute XmlType(Namespace = "http://www.cohowinery.com"
,
    TypeName = "GroupAddress")
 */
public class Address
{
    public String line1;
    public String line2;
    public String city;
    public String state;
    public String zip;
} //Address

public class Group
{
    public Person staff[];
    public Person manager;
    public Address location;
} //Group
継承階層継承階層
System.Object
   System.Attribute
    System.Xml.Serialization.XmlTypeAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlTypeAttribute メンバ
System.Xml.Serialization 名前空間
XmlAttributeOverrides クラス
XmlAttributes クラス
XmlSerializer クラス
XmlAttributes.XmlText プロパティ
XmlAttributes クラス
その他の技術情報
XML シリアル化概要
方法 : XML ストリーム代替要素名を指定する
属性使用した XML シリアル化制御
XML シリアル化の例



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「XmlTypeAttribute クラス」の関連用語

XmlTypeAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlTypeAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS