XmlArrayAttributeとは? わかりやすく解説

XmlArrayAttribute クラス

XmlSerializer が特定のクラス メンバXML 要素配列としてシリアル化する必要があることを指定します

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

<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field
 Or AttributeTargets.Parameter Or AttributeTargets.ReturnValue,
 AllowMultiple:=False)> _
Public Class XmlArrayAttribute
    Inherits Attribute
Dim instance As XmlArrayAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter|AttributeTargets.ReturnValue,
 AllowMultiple=false)] 
public class XmlArrayAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Parameter|AttributeTargets::ReturnValue,
 AllowMultiple=false)] 
public ref class XmlArrayAttribute : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter|AttributeTargets.ReturnValue,
 AllowMultiple=false) */ 
public class XmlArrayAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter|AttributeTargets.ReturnValue,
 AllowMultiple=false) 
public class XmlArrayAttribute extends
 Attribute
解説解説

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

XmlArrayAttribute は、オブジェクト配列返すパブリック フィールドまたは読み取り/書き込みプロパティ適用できます。これはコレクションにも適用できる他、ArrayList を返すフィールド、または IEnumerable インターフェイス実装するオブジェクト返す任意のフィールドにも適用できます

クラス メンバXmlArrayAttribute適用すると、XmlSerializer クラスSerialize メソッドによって、入れ子になった XML 要素シーケンスがこのメンバから生成されます。XML スキーマ ドキュメント (.xsd ファイル) は、このような配列complexType として示します。たとえば、シリアル化するクラスによって発注書を表す場合は、発注品目を表すオブジェクト配列返すパブリック フィールドXmlArrayAttribute適用すると、購入され品目配列生成できます

複合型またはプリミティブ型オブジェクト配列返すパブリック フィールドまたはプロパティにどの属性適用されない場合は、既定では XmlSerializer入れ子になった XML 要素シーケンス生成します生成される XML 要素についてさらに詳細に制御するには、フィールドまたはプロパティに XmlArrayItemAttribute と XmlArrayAttribute適用します。たとえば、既定では、生成される XML 要素の名前はメンバ識別子から派生します。ElementName プロパティ設定すると、生成される XML 要素名を変更できます

指定された型の項目およびこの型から派生したすべてのクラスを含む配列シリアル化するには、XmlArrayItemAttribute使用してそれぞれの型を宣言する必要があります

メモメモ

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

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

使用例使用例

クラス インスタンス複数オブジェクト配列を含む XML ドキュメントシリアル化する例を次に示しますXmlArrayAttribute は、XML 要素配列になるメンバ適用されます。

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml.Serialization
Imports System.Xml


Public Class Run
    
    Public Shared Sub Main()
        Dim test As New
 Run()
        test.SerializeDocument("books.xml")
    End Sub
    
    
    Public Sub SerializeDocument(ByVal
 filename As String)
        ' Creates a new XmlSerializer.
        Dim s As New XmlSerializer(GetType(MyRootClass))
        
        ' Writing the file requires a StreamWriter.
        Dim myWriter As New
 StreamWriter(filename)
        
        ' Creates an instance of the class to serialize. 
        Dim myRootClass As New
 MyRootClass()
        
        ' Uses a basic method of creating an XML array: Create and
        ' populate a string array, and assign it to the
        ' MyStringArray property. 
        
        Dim myString() As String
 =  {"Hello", "world",
 "!"}
        myRootClass.MyStringArray = myString
        
        ' Uses a more advanced method of creating an array:
        ' create instances of the Item and BookItem, where BookItem
        ' is derived from Item. 
        Dim item1 As New
 Item()
        Dim item2 As New
 BookItem()
        
        ' Sets the objects' properties.
        With item1
            .ItemName = "Widget1"
            .ItemCode = "w1"
            .ItemPrice = 231
            .ItemQuantity = 3
        End With

        With item2
            .ItemCode = "w2"
            .ItemPrice = 123
            .ItemQuantity = 7
            .ISBN = "34982333"
            .Title = "Book of Widgets"
            .Author = "John Smith"
        End With
        
        ' Fills the array with the items.
        Dim myItems() As Item =  {item1, item2}
        
        ' Set class's Items property to the array.
        myRootClass.Items = myItems
        
        ' Serializes the class, writes it to disk, and closes
        ' the TextWriter. 
        s.Serialize(myWriter, myRootClass)
        myWriter.Close()
    End Sub
End Class


' This is the class that will be serialized.
Public Class MyRootClass
    Private myItems() As Item
    
    ' Here is a simple way to serialize the array as XML. Using the
    ' XmlArrayAttribute, assign an element name and namespace. The
    ' IsNullable property determines whether the element will be
    ' generated if the field is set to a null value. If set to true
,
    ' the default, setting it to a null value will cause the XML
    ' xsi:null attribute to be generated.
    <XmlArray(ElementName := "MyStrings", _
         Namespace := "http://www.cpandl.com",
 _
         IsNullable := True)> _
    Public MyStringArray() As String
    
    ' Here is a more complex example of applying an
    ' XmlArrayAttribute. The Items property can contain both Item
    ' and BookItem objects. Use the XmlArrayItemAttribute to specify
    ' that both types can be inserted into the array.
    <XmlArrayItem(ElementName := "Item", _
        IsNullable := True, _
        Type := GetType(Item), _
        Namespace := "http://www.cpandl.com"),
 _
     XmlArrayItem(ElementName := "BookItem", _
        IsNullable := True, _
        Type := GetType(BookItem), _
        Namespace := "http://www.cohowinery.com"),
 _
     XmlArray()> _
    Public Property Items As
 Item()
        Get
            Return myItems
        End Get
        Set
            myItems = value
        End Set
    End Property
End Class
 
Public Class Item
    <XmlElement(ElementName := "OrderItem")>
 _
    Public ItemName As String
    Public ItemCode As String
    Public ItemPrice As Decimal
    Public ItemQuantity As Integer
End Class

Public Class BookItem
    Inherits Item
    Public Title As String
    Public Author As String
    Public ISBN As String
End Class

using System;
using System.IO;
using System.Xml.Serialization;
using System.Xml;
 
public class Run
{
   public static void Main()
   {
      Run test = new Run();
      test.SerializeDocument("books.xml");
   }
 
   public void SerializeDocument(string
 filename)
   {
      // Creates a new XmlSerializer.
      XmlSerializer s = 
      new XmlSerializer(typeof(MyRootClass));

      // Writing the file requires a StreamWriter.
      TextWriter myWriter= new StreamWriter(filename);

      // Creates an instance of the class to serialize. 
      MyRootClass myRootClass = new MyRootClass();

      /* Uses a basic method of creating an XML array: Create and 
      populate a string array, and assign it to the 
      MyStringArray property. */

      string [] myString = {"Hello", "world",
 "!"};
      myRootClass.MyStringArray = myString;
       
      /* Uses a more advanced method of creating an array:
         create instances of the Item and BookItem, where BookItem 
         is derived from Item. */
      Item item1 = new Item();
      BookItem item2 = new BookItem();
  
      // Sets the objects' properties.
      item1.ItemName = "Widget1";
      item1.ItemCode = "w1";
      item1.ItemPrice = 231;
      item1.ItemQuantity = 3;
 
      item2.ItemCode = "w2";
      item2.ItemPrice = 123;
      item2.ItemQuantity = 7;
      item2.ISBN = "34982333";
      item2.Title = "Book of Widgets";
      item2.Author = "John Smith";
       
      // Fills the array with the items.
      Item [] myItems = {item1,item2};
       
      // Sets the class's Items property to the array.
      myRootClass.Items = myItems;
 
      /* Serializes the class, writes it to disk, and closes 
         the TextWriter. */
      s.Serialize(myWriter, myRootClass);
      myWriter.Close();
   }
}

// This is the class that will be serialized.
public class MyRootClass
{
   private Item [] items;
 
   /* Here is a simple way to serialize the array as XML. Using the
      XmlArrayAttribute, assign an element name and namespace.
 The
      IsNullable property determines whether the element will be 
      generated if the field is set to a null
 value. If set to true,
      the default, setting it to a null value
 will cause the XML
      xsi:null attribute to be generated. */
   [XmlArray(ElementName = "MyStrings",
   Namespace = "http://www.cpandl.com", IsNullable = true)]
   public string[] MyStringArray;
  
   /* Here is a more complex example of applying an 
      XmlArrayAttribute. The Items property can contain both Item 
      and BookItem objects. Use the XmlArrayItemAttribute to specify
      that both types can be inserted into the array. */
   [XmlArrayItem(ElementName= "Item", 
   IsNullable=true,
   Type = typeof(Item),
   Namespace = "http://www.cpandl.com"),
   XmlArrayItem(ElementName = "BookItem", 
   IsNullable = true, 
   Type = typeof(BookItem),
   Namespace = "http://www.cohowinery.com")]
   [XmlArray]
   public Item []Items
   {
      get{return items;}
      set{items = value;}
   }
}
 
public class Item{
   [XmlElement(ElementName = "OrderItem")]
   public string ItemName;
   public string ItemCode;
   public decimal ItemPrice;
   public int ItemQuantity;
}
 
public class BookItem:Item
{
   public string Title;
   public string Author;
   public string ISBN;
}
   
#using <System.Xml.dll>
#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml::Serialization;
using namespace System::Xml;
public ref class Item
{
public:

   [XmlElement(ElementName="OrderItem")]
   String^ ItemName;
   String^ ItemCode;
   Decimal ItemPrice;
   int ItemQuantity;
};

public ref class BookItem: public
 Item
{
public:
   String^ Title;
   String^ Author;
   String^ ISBN;
};

// This is the class that will be serialized.
public ref class MyRootClass
{
private:
   array<Item^>^items;

public:

   /* Here is a simple way to serialize the array as XML. Using the
         XmlArrayAttribute, assign an element name and namespace.
 The
         IsNullable property determines whether the element will be 
         generated if the field is set to a null
 value. If set to true,
         the default, setting it to a null value
 will cause the XML
         xsi:null attribute to be generated. */

   [XmlArray(ElementName="MyStrings",
   Namespace="http://www.cpandl.com",IsNullable=true)]
   array<String^>^MyStringArray;

   /* Here is a more complex example of applying an 
         XmlArrayAttribute. The Items property can contain both Item 
         and BookItem objects. Use the XmlArrayItemAttribute to specify
         that both types can be inserted into the array. */
   [XmlArrayItem(ElementName="Item",
   IsNullable=true,
   Type=Item::typeid,
   Namespace="http://www.cpandl.com"),
   XmlArrayItem(ElementName="BookItem",
   IsNullable=true,
   Type=BookItem::typeid,
   Namespace="http://www.cohowinery.com")]
   [XmlArray]
   property array<Item^>^ Items 
   {
      array<Item^>^ get()
      {
         return items;
      }

      void set( array<Item^>^value )
      {
         items = value;
      }
   }
};

public ref class Run
{
public:
   void SerializeDocument( String^ filename )
   {
      // Creates a new XmlSerializer.
      XmlSerializer^ s = gcnew XmlSerializer( MyRootClass::typeid );

      // Writing the file requires a StreamWriter.
      TextWriter^ myWriter = gcnew StreamWriter( filename );

      // Creates an instance of the class to serialize. 
      MyRootClass^ myRootClass = gcnew MyRootClass;

      /* Uses a basic method of creating an XML array: Create and 
            populate a string array, and assign it to the 
            MyStringArray property. */
      array<String^>^myString = {"Hello","world","!"};
      myRootClass->MyStringArray = myString;

      /* Uses a more advanced method of creating an array:
               create instances of the Item and BookItem, where BookItem 
               is derived from Item. */
      Item^ item1 = gcnew Item;
      BookItem^ item2 = gcnew BookItem;

      // Sets the objects' properties.
      item1->ItemName = "Widget1";
      item1->ItemCode = "w1";
      item1->ItemPrice = 231;
      item1->ItemQuantity = 3;
      item2->ItemCode = "w2";
      item2->ItemPrice = 123;
      item2->ItemQuantity = 7;
      item2->ISBN = "34982333";
      item2->Title = "Book of Widgets";
      item2->Author = "John Smith";

      // Fills the array with the items.
      array<Item^>^myItems = {item1,item2};

      // Sets the class's Items property to the array.
      myRootClass->Items = myItems;

      /* Serializes the class, writes it to disk, and closes 
               the TextWriter. */
      s->Serialize( myWriter, myRootClass );
      myWriter->Close();
   }
};

int main()
{
   Run^ test = gcnew Run;
   test->SerializeDocument( "books.xml" );
}
import System.*;
import System.IO.*;
import System.Xml.Serialization.*;
import System.Xml.*;

public class Run
{
    public static void main(String[]
 args)
    {
        Run test = new Run();
        test.SerializeDocument("books.xml");
    } //main

    public void SerializeDocument(String fileName)
    {
        // Creates a new XmlSerializer.
        XmlSerializer s = new XmlSerializer(MyRootClass.class.ToType());

        // Writing the file requires a StreamWriter.
        TextWriter myWriter = new StreamWriter(fileName);

        // Creates an instance of the class to serialize. 
        MyRootClass myRootClass = new MyRootClass();

        /* Uses a basic method of creating an XML array: Create and 
           populate a string array, and assign it to the 
           MyStringArray property. 
        */
        String myString[] =  { "Hello", "world", "!"
 };
        myRootClass.myStringArray = myString;

        /* Uses a more advanced method of creating an array:
           create instances of the Item and BookItem, where BookItem 
           is derived from Item. 
        */
        Item item1 = new Item();
        BookItem item2 = new BookItem();

        // Sets the objects' properties.
        item1.itemName = "Widget1";
        item1.itemCode = "w1";
        item1.itemPrice = Convert.ToDecimal(231);
        item1.itemQuantity = 3;

        item2.itemCode = "w2";
        item2.itemPrice = Convert.ToDecimal(123);
        item2.itemQuantity = 7;
        item2.isbn = "34982333";
        item2.title = "Book of Widgets";
        item2.author = "John Smith";

        // Fills the array with the items.
        Item myItems[] =  { item1, item2 };

        // Sets the class's Items property to the array.
        myRootClass.set_Items(myItems);

        /* Serializes the class, writes it to disk, and closes
 
           the TextWriter. 
        */
        s.Serialize(myWriter, myRootClass);
        myWriter.Close();
    } //SerializeDocument
} //Run

// This is the class that will be serialized.
public class MyRootClass
{
    private Item items[];

    /* Here is a simple way to serialize the array as XML. Using the
       XmlArrayAttribute, assign an element name and namespace.
 The
       IsNullable property determines whether the element will be 
       generated if the field is set to a null
 value. If set to true,
       the default, setting it to a null value
 will cause the XML
       xsi:null attribute to be generated. 
    */
    /** @attribute XmlArray(ElementName = "MyStrings", 
        Namespace = "http://www.cpandl.com", IsNullable =
 true)
     */
    public String myStringArray[];

    /* Here is a more complex example of applying an 
       XmlArrayAttribute. The Items property can contain both Item 
       and BookItem objects. Use the XmlArrayItemAttribute to specify
       that both types can be inserted into the array. 
    */

    /** @attribute XmlArrayItem(ElementName = "Item", IsNullable = true,
 
        Type = Item.class, Namespace = "http://www.cpandl.com")
        @attribute XmlArrayItem(ElementName = "BookItem", IsNullable =
 true, 
        Type = BookItem.class, Namespace = "http://www.cohowinery.com")
     */
    /** @attribute XmlArray()
     */
    /** @property 
     */
    public Item[] get_Items()
    {
        return items;
    } //get_Items

    /** @property 
     */
    public void set_Items(Item[] value)
    {
        items = value;
    } //set_Items
} //MyRootClass

public class Item
{
    /** @attribute XmlElement(ElementName = "OrderItem")
     */
    public String itemName;
    public String itemCode;
    public System.Decimal itemPrice;
    public int itemQuantity;
} //Item

public class BookItem extends Item
{
    public String title;
    public String author;
    public String isbn;
} //BookItem
継承階層継承階層
System.Object
   System.Attribute
    System.Xml.Serialization.XmlArrayAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlArrayAttribute メンバ
System.Xml.Serialization 名前空間
XmlArray
XmlArrayItemAttribute
XmlAttributeOverrides
XmlAttributes
XmlAttributes
その他の技術情報
XML シリアル化概要
方法 : XML ストリーム代替要素名を指定する
属性使用した XML シリアル化制御
XML シリアル化の例
XML スキーマ定義ツール (Xsd.exe)

XmlArrayAttribute コンストラクタ ()

XmlArrayAttribute クラス新しインスタンス初期化します。

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

Dim instance As New XmlArrayAttribute
public XmlArrayAttribute ()
public:
XmlArrayAttribute ()
public XmlArrayAttribute ()
public function XmlArrayAttribute ()
解説解説
使用例使用例

XmlArrayAttribute2 つ配列代入する例を次に示します

Public Class MyClass1
    <XmlArrayAttribute()> Public MyStringArray() As
 String
    <XmlArrayAttribute()> Public MyIntegerArray() As
 Integer
End Class

public class MyClass
{
    [XmlArrayAttribute()]
    public string [] MyStringArray;
    [XmlArrayAttribute()]
    public int [] MyIntegerArray;
}

public ref class MyClass
{
public:

   [XmlArrayAttribute]
   array<String^>^MyStringArray;

   [XmlArrayAttribute]
   array<Int32>^MyIntegerArray;
};

public class MyClass
{
    /** @attribute XmlArrayAttribute()
     */
    public String myStringArray[];

    /** @attribute XmlArrayAttribute()
     */
    public int myIntegerArray[];
} //MyClass
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlArrayAttribute クラス
XmlArrayAttribute メンバ
System.Xml.Serialization 名前空間
XmlArrayItemAttribute
XmlSerializer

XmlArrayAttribute コンストラクタ (String)

XmlArrayAttribute クラス新しインスタンス初期化しXML ドキュメント インスタンス生成される XML 要素名を指定します

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

Public Sub New ( _
    elementName As String _
)
Dim elementName As String

Dim instance As New XmlArrayAttribute(elementName)
public XmlArrayAttribute (
    string elementName
)
public:
XmlArrayAttribute (
    String^ elementName
)
public XmlArrayAttribute (
    String elementName
)
public function XmlArrayAttribute (
    elementName : String
)

パラメータ

elementName

XmlSerializer が生成する XML 要素の名前。

解説解説
使用例使用例

XmlArrayAttribute2 つ配列代入し、これらの配列を含むクラス インスタンスシリアル化する例を次に示します

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization


Public Class MyClass1
    <XmlArrayAttribute("MyStrings")> _
        Public MyStringArray() As String

    <XmlArrayAttribute(ElementName := "MyIntegers")>
 _
        Public MyIntegerArray() As Integer
End Class


Public Class Run
    
    Public Shared Sub Main()
        Dim test As New
 Run()
        test.SerializeObject("MyClass.xml")
    End Sub    
    
    Public Sub SerializeObject(ByVal
 filename As String)
        ' Creates a new instance of the XmlSerializer class.
        Dim s As New XmlSerializer(GetType(MyClass1))
        ' Needed a StreamWriter to write the file.
        Dim myWriter As New
 StreamWriter(filename)
        
        Dim class1 As New
 MyClass1()
        ' Creates and populates a string array, then assigns
        ' it to the MyStringArray property.
        Dim myStrings() As String
 =  {"Hello", "World",
 "!"}
        class1.MyStringArray = myStrings
        ' Creates and populates an integer array, and assigns
        ' it to the MyIntegerArray property.
        Dim myIntegers() As Integer
 =  {1, 2, 3}
        class1.MyIntegerArray = myIntegers
        ' Serializes the class, and writes it to disk.
        s.Serialize(myWriter, class1)
        myWriter.Close()
    End Sub
End Class

using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
 
public class MyClass{
   [XmlArrayAttribute("MyStrings")]
   public string [] MyStringArray;
   [XmlArrayAttribute(ElementName = "MyIntegers")]
   public int [] MyIntegerArray;
}
 
public class Run{
   public static void Main()
   {
      Run test = new Run();
      test.SerializeObject("MyClass.xml");
   }
 
   public void SerializeObject(string
 filename)
   {
      // Creates a new instance of the XmlSerializer class.
      XmlSerializer s = new XmlSerializer(typeof(MyClass));
      // Needs a StreamWriter to write the file.
      TextWriter myWriter= new StreamWriter(filename);
 
      MyClass myClass = new MyClass();
      // Creates and populates a string array, then assigns
      // it to the MyStringArray property.
      string [] myStrings = {"Hello", "World",
 "!"};
      myClass.MyStringArray = myStrings;
      /* Creates and populates an integer array, and assigns
      it to the MyIntegerArray property. */
      int [] myIntegers = {1,2,3};
      myClass.MyIntegerArray = myIntegers;     
      // Serializes the class, and writes it to disk.
      s.Serialize(myWriter, myClass);
      myWriter.Close();
   }
}

#using <System.Xml.dll>
#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Xml::Serialization;

public ref class MyClass
{
public:

   [XmlArrayAttribute("MyStrings")]
   array<String^>^MyStringArray;

   [XmlArrayAttribute(ElementName="MyIntegers")]
   array<Int32>^MyIntegerArray;
};

int main()
{
   String^ filename = "MyClass.xml";

   // Creates a new instance of the XmlSerializer class.
   XmlSerializer^ s = gcnew XmlSerializer( MyClass::typeid );

   // Needs a StreamWriter to write the file.
   TextWriter^ myWriter = gcnew StreamWriter( filename );
   MyClass^ myClass = gcnew MyClass;

   // Creates and populates a string array, then assigns
   // it to the MyStringArray property.
   array<String^>^myStrings = {"Hello","World","!"};
   myClass->MyStringArray = myStrings;

   /* Creates and populates an integer array, and assigns
      it to the MyIntegerArray property. */
   array<Int32>^myIntegers = {1,2,3};
   myClass->MyIntegerArray = myIntegers;

   // Serializes the class, and writes it to disk.
   s->Serialize( myWriter, myClass );
   myWriter->Close();
}
import System.*;
import System.IO.*;
import System.Xml.*;
import System.Xml.Serialization.*;

public class MyClass
{
    /** @attribute XmlArrayAttribute("MyStrings")
     */
    public String myStringArray[];

    /** @attribute XmlArrayAttribute(ElementName = "MyIntegers")
     */
    public int myIntegerArray[];
} //MyClass

public class Run
{
    public static void main(String[]
 args)
    {
        Run test = new Run();
        test.SerializeObject("MyClass.xml");
    } //main

    public void SerializeObject(String fileName)
    {
        // Creates a new instance of the XmlSerializer class.
        XmlSerializer s = new XmlSerializer(MyClass.class.ToType());

        // Needs a StreamWriter to write the file.
        TextWriter myWriter = new StreamWriter(fileName);
        MyClass myClass = new MyClass();

        // Creates and populates a string array, then assigns
        // it to the MyStringArray property.
        String myStrings[] =  { "Hello", "World", "!"
 };
        myClass.myStringArray = myStrings;

        /* Creates and populates an integer array, and assigns
           it to the MyIntegerArray property. 
        */
        int myIntegers[] =  { 1, 2, 3 };
        myClass.myIntegerArray = myIntegers;

        // Serializes the class, and writes it to disk.
        s.Serialize(myWriter, myClass);
        myWriter.Close();
    } //SerializeObject
} //Run
<?xml version="1.0"?>
 <MyClass1 xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/1999/XMLSchema">
   <MyStrings>
     <string>Hello</string>
     <string>World</string>
     <string>!</string>
   </MyStrings>
   <MyIntegers>
     <int>1</int>
     <int>2</int>
     <int>3</int>
   </MyIntegers>
 </MyClass1>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlArrayAttribute クラス
XmlArrayAttribute メンバ
System.Xml.Serialization 名前空間
XmlArrayItemAttribute
XmlSerializer

XmlArrayAttribute コンストラクタ

XmlArrayAttribute クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

XmlArrayAttribute クラス
XmlArrayAttribute メンバ
System.Xml.Serialization 名前空間
XmlArrayItemAttribute
XmlSerializer

XmlArrayAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
参照参照

関連項目

XmlArrayAttribute クラス
System.Xml.Serialization 名前空間
XmlArray
XmlArrayItemAttribute
XmlAttributeOverrides
XmlAttributes
XmlAttributes

その他の技術情報

XML シリアル化概要
方法 : XML ストリーム代替要素名を指定する
属性使用した XML シリアル化制御
XML シリアル化の例
XML スキーマ定義ツール (Xsd.exe)

XmlArrayAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスハッシュ コード返します。 ( Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラス既定値かどうか示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

XmlArrayAttribute クラス
System.Xml.Serialization 名前空間
XmlArray
XmlArrayItemAttribute
XmlAttributeOverrides
XmlAttributes
XmlAttributes

その他の技術情報

XML シリアル化概要
方法 : XML ストリーム代替要素名を指定する
属性使用した XML シリアル化制御
XML シリアル化の例
XML スキーマ定義ツール (Xsd.exe)

XmlArrayAttribute メンバ

XmlSerializer が特定のクラス メンバXML 要素配列としてシリアル化する必要があることを指定します

XmlArrayAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド XmlArrayAttribute オーバーロードされます。 XmlArrayAttribute クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート .NET Compact Framework によるサポート TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスハッシュ コード返します。 (Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラス既定値かどうか示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

XmlArrayAttribute クラス
System.Xml.Serialization 名前空間
XmlArray
XmlArrayItemAttribute
XmlAttributeOverrides
XmlAttributes
XmlAttributes

その他の技術情報

XML シリアル化概要
方法 : XML ストリーム代替要素名を指定する
属性使用した XML シリアル化制御
XML シリアル化の例
XML スキーマ定義ツール (Xsd.exe)



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

辞書ショートカット

すべての辞書の索引

「XmlArrayAttribute」の関連用語

XmlArrayAttributeのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS