XmlArrayItemAttribute.NestingLevel プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlArrayItemAttribute.NestingLevel プロパティの意味・解説 

XmlArrayItemAttribute.NestingLevel プロパティ

XmlArrayItemAttribute が影響与えXML 要素階層構造レベル取得または設定します

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

Dim instance As XmlArrayItemAttribute
Dim value As Integer

value = instance.NestingLevel

instance.NestingLevel = value
public int NestingLevel { get;
 set; }
public:
property int NestingLevel {
    int get ();
    void set (int value);
}
/** @property */
public int get_NestingLevel ()

/** @property */
public void set_NestingLevel (int
 value)
public function get NestingLevel
 () : int

public function set NestingLevel
 (value : int)

プロパティ
複数配列内の 1 つ配列内のインデックスセットの 0 から始まるインデックス番号

解説解説

XML ドキュメントは、XML 要素階層構造含めることができますこのような階層構造を表すために、複数配列の中から 1 つ配列使用されます。このような配列内では、各インデックス階層構造レベル表しますこのためNestingLevel プロパティは、複数配列の中の 1 つ配列返すフィールドXmlArrayItemAttribute適用するときにだけ使用されます。

属性適用する場合は、NestingLevel設定することにより、属性影響与え階層構造レベルはどれかを指定します最初インデックスは、常に値 0 です。そのため、その NestingLevel設定任意です。NestingLevel 値を持たない XmlArrayItemAttribute は、最初配列インデックス適用されます。NestingLevel 値の指定 (1、2、3 など) が必須なのは、後続XmlArrayItemAttribute オブジェクトについてのみです。

使用例使用例

配列配列3 つの XmlArrayItemAttribute 属性提供する例を次に示します。各属性適用先配列指定するために、NestingLevel プロパティ配列インデックス設定してます。

using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

public class Forest{
   /* Set the NestingLevel for each array. The first 
   attribute (NestingLevel = 0) is optional. */
   [XmlArrayItem(ElementName = "tree", NestingLevel = 0)]
   [XmlArrayItem(ElementName = "branch", NestingLevel = 1)]
   [XmlArrayItem(ElementName = "leaf",NestingLevel = 2)]
   public string[][][] TreeArray;
}

public class Test{
   public static void Main(){
      Test t = new Test();
      t.SerializeObject("Tree.xml");
   }
   private void SerializeObject(string
 filename){
      XmlSerializer serializer = 
      new XmlSerializer(typeof(Forest));

      Forest f = new Forest();
      string[][][] myTreeArray = new string[2]
 [][];

      string[][]myBranchArray1= new string[1][];
      myBranchArray1[0]=new string[1]{"One"};
      myTreeArray[0]=myBranchArray1;

      string[][]myBranchArray2= new string[2][];
      myBranchArray2[0]=new string[2]{"One"
,"Two"};
      myBranchArray2[1]=new string[3]{"One"
,"Two","Three"};
      myTreeArray[1]=myBranchArray2;
   
      f.TreeArray=myTreeArray;

     serializer.Serialize(Console.Out, f);
   }
}
#using <System.dll>
#using <System.Xml.dll>

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

public ref class Forest
{
    // Set the NestingLevel for each array. The first
    // attribute (NestingLevel = 0) is optional.
public:
    [XmlArrayItem(ElementName = "tree", NestingLevel = 0)]
    [XmlArrayItem(ElementName = "branch", NestingLevel = 1)]
    [XmlArrayItem(ElementName = "leaf",NestingLevel = 2)]
    array<array<array<String^>^>^>^ TreeArray;
};

int main()
{
    XmlSerializer^ serializer = gcnew XmlSerializer(Forest::typeid);

    Forest^ constructedForest = gcnew Forest();
    array<array<array<String^>^>^>^ tree = 
        gcnew array<array<array<String^>^>^>(2);

    array<array<String^>^>^ firstBranch = gcnew array<array<String^>^>(1);
    firstBranch[0] = gcnew array<String^>{"One"};
    tree[0] = firstBranch;

    array<array<String^>^>^ secondBranch = gcnew array<array<String^>^>(2);
    secondBranch[0] = gcnew array<String^>{"One","Two"};
    secondBranch[1] = gcnew array<String^>{"One","Two"
,"Three"};
    tree[1] = secondBranch;

    constructedForest->TreeArray = tree;

    serializer->Serialize(Console::Out, constructedForest);
}

#using <mscorlib.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
using namespace System::Xml::Serialization;
using namespace System::IO;

public __gc class Forest{
   /* Set the NestingLevel for each array. The first 
   attribute (NestingLevel = 0) is optional. */
public:
   [XmlArrayItem(ElementName = S"tree", NestingLevel = 0)]
   [XmlArrayItem(ElementName = S"branch", NestingLevel = 1)]
   [XmlArrayItem(ElementName = S"leaf",NestingLevel = 2)]
   String* TreeArray[][][];
};

public __gc class Test{
public:
   static void main(){
      Test* t = new Test();
      t->SerializeObject(S"Tree.xml");
   }
private:
   void SerializeObject(String* /*filename*/){
      XmlSerializer* serializer = 
      new XmlSerializer(__typeof(Forest));

      Forest* f = new Forest();
      String* myTreeArray[][][] = new String*[][][2];

      String* myBranchArray1[][] = new String*[][1];
      myBranchArray1[0]=new String*[1]{S"One"};
      myTreeArray[0]=myBranchArray1;

      String* myBranchArray2[][] = new String*[][2];
      myBranchArray2[0]=new String*[2]{S"One",S"Two"};
      myBranchArray2[1]=new String*[3]{S"One",S"Two",S"Three"};
      myTreeArray[1]=myBranchArray2;
   
      f->TreeArray=myTreeArray;

      serializer->Serialize(Console::Out, f);
   }
};

int main(){
   Test::main();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlArrayItemAttribute クラス
XmlArrayItemAttribute メンバ
System.Xml.Serialization 名前空間



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

辞書ショートカット

すべての辞書の索引

XmlArrayItemAttribute.NestingLevel プロパティのお隣キーワード
検索ランキング

   

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



XmlArrayItemAttribute.NestingLevel プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS