XmlReader.ReadSubtree メソッド
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlReader Dim returnValue As XmlReader returnValue = instance.ReadSubtree
ReadState.Initial に設定された新しい XmlReader インスタンス。Read メソッドを呼び出すと、ReadSubtree メソッドを呼び出す前に処理対象だったノードに新しい XmlReader が配置されます。


ReadSubtree は、要素ノードでのみ呼び出すことができます。サブツリー全体が既に読み取られている場合に Read メソッドを呼び出すと、false が返されます。新しい XmlReader を閉じると、元の XmlReader はサブツリーの EndElement ノードに配置されます。したがって、ReadSubtree メソッドを book 要素の開始タグで呼び出した場合は、サブツリーが読み取られ、新しい XmlReader が閉じられた後、元の XmlReader が book 要素の終了タグに配置されます。
新しい XmlReader が閉じられるまで、元の XmlReader で操作を実行しないでください。このアクションはサポートされていないため、予測できない動作が発生する可能性があります。
![]() |
---|
ReadSubtree メソッドは、XML データのコピーを作成して、別個に扱うような使い方は想定されていません。このメソッドの主な目的は、XML 要素の境界を定義することにあります。たとえば、データを別のコンポーネントに渡して処理させたり、コンポーネントがアクセスできるデータのサイズを制限したりする場合に使用します。ReadSubtree メソッドから返された XmlReader を別のアプリケーションに渡すことにより、そのアプリケーションが、XML ドキュメント全体にアクセスすることなく、特定の XML 要素だけにアクセスできます。 |

ReadSubtree メソッドを使用する方法の例を次に示します。
Dim settings As New XmlReaderSettings() settings.IgnoreWhitespace = True Using reader As XmlReader = XmlReader.Create("books.xml", settings) ' Position the reader on the second book node. reader.ReadToFollowing("book") reader.Skip() ' Create another reader that contains just the second book node. Dim inner As XmlReader = reader.ReadSubtree() ' Do additional processing on the inner reader. After you ' are done, you can call Close on the inner reader and ' continue processing using the original reader. End Using
XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; using (XmlReader reader = XmlReader.Create("books.xml", settings)) { // Position the reader on the second book node reader.ReadToFollowing("book"); reader.Skip(); // Create another reader that contains just the second book node. XmlReader inner = reader.ReadSubtree(); // Do additional processing on the inner reader. After you // are done, you can call Close on the inner reader and // continue processing using the original reader. }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlReader.ReadSubtree メソッドを検索する場合は、下記のリンクをクリックしてください。

- XmlReader.ReadSubtree メソッドのページへのリンク