XmlReader.ReadInnerXml メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlReader.ReadInnerXml メソッドの意味・解説 

XmlReader.ReadInnerXml メソッド

派生クラスオーバーライドされると、マークアップを含むすべての内容文字列として読み取ります。

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

例外例外
解説解説

このメソッドは、マークアップ含め現在のノード内容のすべてを返します現在のノード (開始タグ) および対応する終了ノード (終了タグ) は返されません。たとえば、次の場合

 <node>
  this <child/>
 </node>

ReadInnerXml 返される結果次のようになりますthis <child/>

このメソッドは、要素ノードおよび属性ノード次の方法処理します

ノード

呼び出し前の位置

XML フラグメント

戻り値

呼び出し後の位置

Element

item1 開始タグ上。

<item1>text1</item1><item2>text2</item2>

text1

item2 開始タグ上。

Attribute

attr1 属性ノード上。

<item attr1="val1" attr2="val2">text</item>

val1

attr1 属性ノード残しておきます

リーダーリーフ ノード配置すると、ReadInnerXml呼び出しは、Read呼び出し等しくなりますメソッドString.Empty返します (ただし、属性ノード場合属性の値を返します)。

このメソッドは、整形式XML かどうかチェックしますReadInnerXml が XmlValidatingReader から呼び出され場合返され内容検証します。

ReadOuterXml メソッドは、XmlNodeReader クラス、XmlTextReader クラス、および XmlValidatingReader クラス実装されるため、名前空間認識します

使用例使用例

ReadInnerXml メソッドと ReadOuterXml メソッド比較する例を次に示します

' Load the file and ignore all white space.
Dim settings As New XmlReaderSettings()
settings.IgnoreWhitespace = True
Using reader As XmlReader = XmlReader.Create("2books.xml")

  ' Moves the reader to the root element.
  reader.MoveToContent()
                
  ' Moves to book node.
  reader.Read()
                
  ' Note that ReadInnerXml only returns the markup of the node's children
  ' so the book's attributes are not returned.
  Console.WriteLine("Read the first book using ReadInnerXml...")
  Console.WriteLine(reader.ReadInnerXml())
                
  ' ReadOuterXml returns the markup for the current node and its children
  ' so the book's attributes are also returned.
  Console.WriteLine("Read the second book using ReadOuterXml...")
  Console.WriteLine(reader.ReadOuterXml())

End Using
// Load the file and ignore all white space.
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
using (XmlReader reader = XmlReader.Create("2books.xml"))
 {

  // Moves the reader to the root element.
  reader.MoveToContent();
 
  // Moves to book node.
  reader.Read(); 

  // Note that ReadInnerXml only returns the markup of the node's children
  // so the book's attributes are not returned.
  Console.WriteLine("Read the first book using ReadInnerXml...");
  Console.WriteLine(reader.ReadInnerXml());

  // ReadOuterXml returns the markup for the current node and its children
  // so the book's attributes are also returned.
  Console.WriteLine("Read the second book using ReadOuterXml...");
  Console.WriteLine(reader.ReadOuterXml());      

}

この例では、入力として、2books.xml というファイル使用してます。

<!--sample XML fragment-->
<bookstore>
  <book genre='novel' ISBN='10-861003-324'>
    <title>The Handmaid's
 Tale</title>
    <price>19.95</price>
  </book>
  <book genre='novel' ISBN='1-861001-57-5'>
    <title>Pride
 And Prejudice</title>
    <price>24.95</price>
  </book>
</bookstore>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からXmlReader.ReadInnerXml メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からXmlReader.ReadInnerXml メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からXmlReader.ReadInnerXml メソッド を検索

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

辞書ショートカット

すべての辞書の索引

XmlReader.ReadInnerXml メソッドのお隣キーワード
検索ランキング

   

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



XmlReader.ReadInnerXml メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS