XmlReader.IsStartElementとは? わかりやすく解説

XmlReader.IsStartElement メソッド ()

MoveToContent を呼び出し、現在のコンテンツ ノードが開始タグまたは空の要素タグかどうかをテストします。

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

Public Overridable Function
 IsStartElement As Boolean
public virtual bool IsStartElement ()
public:
virtual bool IsStartElement ()
public boolean IsStartElement ()
public function IsStartElement () : boolean

戻り値
MoveToContent が開始タグまたは空の要素タグを見つけた場合は true。XmlNodeType.Element 以外のノード型が見つかった場合は false。

例外例外
解説解説
使用例使用例

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

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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

XmlReader.IsStartElement メソッド (String, String)

MoveToContent を呼び出し、現在のコンテンツ ノードが開始タグまたは空の要素タグかどうか、また、見つかった要素の LocalName プロパティと NamespaceURI プロパティが、指定した文字列と一致するかどうかをテストします。

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

Public Overridable Function
 IsStartElement ( _
    localname As String, _
    ns As String _
) As Boolean
Dim instance As XmlReader
Dim localname As String
Dim ns As String
Dim returnValue As Boolean

returnValue = instance.IsStartElement(localname, ns)
public virtual bool IsStartElement (
    string localname,
    string ns
)
public:
virtual bool IsStartElement (
    String^ localname, 
    String^ ns
)
public boolean IsStartElement (
    String localname, 
    String ns
)
public function IsStartElement (
    localname : String, 
    ns : String
) : boolean

パラメータ

localname

見つかった要素の LocalName プロパティと一致する文字列。

ns

見つかった要素の NamespaceURI プロパティと一致する文字列。

戻り値
見つかったノードが要素の場合は true。XmlNodeType.Element 以外のノード型が見つかった場合、または要素の LocalName プロパティと NamespaceURI プロパティが指定した文字列と一致しない場合は false。

例外例外
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

XmlReader.IsStartElement メソッド

XmlReader による XML の読み取り

XmlReader.IsStartElement メソッド (String)

MoveToContent を呼び出し、現在のコンテンツ ノードが開始タグまたは空の要素タグかどうか、また、見つかった要素の Name プロパティが、指定した引数と一致するかどうかをテストします。

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

例外例外
解説解説
使用例使用例

個々の価格要素を表示する例を次に示します。

' Parse the file and display each price node.
While reader.Read()
  If reader.IsStartElement("price")
 Then
    Console.WriteLine(reader.ReadInnerXml())
  End If
End While
// Parse the file and display each price node.
while (reader.Read()) {
  if (reader.IsStartElement("price")) {
     Console.WriteLine(reader.ReadInnerXml());
  }
}   
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

カテゴリ一覧

すべての辞書の索引



Weblioのサービス

「XmlReader.IsStartElement」の関連用語


XmlReader.IsStartElementのお隣キーワード
検索ランキング

   

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



XmlReader.IsStartElementのページの著作権

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

©2026 GRAS Group, Inc.RSS