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

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

XmlReader.IsEmptyElement プロパティ

派生クラスオーバーライドされると、現在のノードが空の要素 (<MyElement/> など) かどうかを示す値を取得します

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

Public MustOverride ReadOnly
 Property IsEmptyElement As Boolean
Dim instance As XmlReader
Dim value As Boolean

value = instance.IsEmptyElement
public abstract bool IsEmptyElement { get;
 }
/** @property */
public abstract boolean get_IsEmptyElement ()

プロパティ
現在のノード/> で終わる要素である (NodeType が XmlNodeType.Element等しい) 場合trueそれ以外場合false

解説解説

このプロパティ使用すると、次の 2 つ違い確認できます

<item num="123"/> (IsEmptyElementtrue)。

<item num="123"></item> (IsEmptyElementfalse。ただし要素内容は空)。

対応する EndElement ノードは、空の要素に対して生成されません。

スキーマ検証により既定内容要素追加され場合でも、IsEmptyElementtrue返します要素既定値含まれているかどうかは関係ありません。つまり IsEmptyElement は、ソース ドキュメント内の要素終了要素タグがあるかどうかだけを報告します

使用例使用例

各要素テキストの内容表示する例を次に示します

While reader.Read()
  If reader.IsStartElement() Then
    If reader.IsEmptyElement Then
      Console.WriteLine("<{0}/>", reader.Name)
    Else
      Console.Write("<{0}> ", reader.Name)
      reader.Read() ' Read the start tag.
      If reader.IsStartElement() Then '
 Handle nested elements.
        Console.Write(vbCr + vbLf + "<{0}>",
 reader.Name)
      End If
      Console.WriteLine(reader.ReadString()) 'Read the text content
 of the element.
    End If
  End If
End While
while (reader.Read()) {
  if (reader.IsStartElement()) {
    if (reader.IsEmptyElement)
      Console.WriteLine("<{0}/>", reader.Name);
    else {
      Console.Write("<{0}> ", reader.Name);
      reader.Read(); // Read the start tag.
      if (reader.IsStartElement())  // Handle nested
 elements.
        Console.Write("\r\n<{0}>", reader.Name);
      Console.WriteLine(reader.ReadString());  //Read the text content
 of the element.
    }
  } 
} 

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

<book>
  <title>Pride And
 Prejudice</title>
  <price>19.95</price>
  <misc/>
</book>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS