XmlArrayItemAttribute.NestingLevel プロパティ
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlArrayItemAttribute Dim value As Integer value = instance.NestingLevel instance.NestingLevel = value
/** @property */ public int get_NestingLevel () /** @property */ public void set_NestingLevel (int value)
複数の配列内の 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(); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- XmlArrayItemAttribute.NestingLevel プロパティのページへのリンク