XmlReader.IsStartElement 메서드

정의

현재 콘텐츠 노드가 시작 태그인지 테스트합니다.

오버로드

IsStartElement(String, String)

MoveToContent()를 호출하고 현재 콘텐츠 노드가 시작 태그 또는 빈 요소 태그인지 여부와 찾은 요소의 LocalNameNamespaceURI 속성이 지정된 인수와 일치하는지 여부를 테스트합니다.

IsStartElement()

MoveToContent()를 호출하고 현재 콘텐츠 노드가 시작 태그 또는 빈 요소 태그인지 테스트합니다.

IsStartElement(String)

MoveToContent()를 호출하고 현재 콘텐츠 노드가 시작 태그 또는 빈 요소 태그인지 여부와 찾은 요소의 Name 속성이 지정된 인수와 일치하는지 여부를 테스트합니다.

IsStartElement(String, String)

Source:
XmlReader.cs
Source:
XmlReader.cs
Source:
XmlReader.cs

MoveToContent()를 호출하고 현재 콘텐츠 노드가 시작 태그 또는 빈 요소 태그인지 여부와 찾은 요소의 LocalNameNamespaceURI 속성이 지정된 인수와 일치하는지 여부를 테스트합니다.

public:
 virtual bool IsStartElement(System::String ^ localname, System::String ^ ns);
public virtual bool IsStartElement (string localname, string ns);
abstract member IsStartElement : string * string -> bool
override this.IsStartElement : string * string -> bool
Public Overridable Function IsStartElement (localname As String, ns As String) As Boolean

매개 변수

localname
String

찾은 요소의 LocalName 속성과 일치하는 문자열입니다.

ns
String

찾은 요소의 NamespaceURI 속성과 일치하는 문자열입니다.

반환

테스트한 결과 현재 노드가 요소이면 true이고, false 이외의 노드 형식을 찾거나 요소의 XmlNodeType.ElementLocalName 속성이 지정된 문자열과 일치하지 않으면 NamespaceURI입니다.

예외

입력 스트림에 잘못된 XML이 있는 경우

이전 비동기 작업이 완료되기 전에 XmlReader 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

설명

이 메서드는 판독기가 콘텐츠 노드에 배치될 때까지 공백, 주석 및 처리 지침을 건너뜁니다. 그런 다음 메서드는 현재 노드가 요소인지 테스트합니다.

추가 정보

적용 대상

IsStartElement()

Source:
XmlReader.cs
Source:
XmlReader.cs
Source:
XmlReader.cs

MoveToContent()를 호출하고 현재 콘텐츠 노드가 시작 태그 또는 빈 요소 태그인지 테스트합니다.

public:
 virtual bool IsStartElement();
public virtual bool IsStartElement ();
abstract member IsStartElement : unit -> bool
override this.IsStartElement : unit -> bool
Public Overridable Function IsStartElement () As Boolean

반환

MoveToContent()가 시작 태그나 빈 요소 태그를 찾으면 true이고, false 이외의 노드 형식을 찾으면 XmlNodeType.Element입니다.

예외

입력 스트림에 잘못된 XML이 있는 경우

이전 비동기 작업이 완료되기 전에 XmlReader 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

예제

다음 예제에서는 각 요소의 텍스트 내용을 표시합니다.

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.
    }
  }
}
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

이 예제에서는 파일 를 elems.xml입력으로 사용합니다.

<book>
  <title>Pride And Prejudice</title>
  <price>19.95</price>
  <misc/>
</book>

설명

이 메서드는 판독기가 콘텐츠 노드에 배치될 때까지 공백, 주석 및 처리 지침을 건너뜁니다. 그런 다음 메서드는 현재 노드가 요소인지 테스트합니다.

추가 정보

적용 대상

IsStartElement(String)

Source:
XmlReader.cs
Source:
XmlReader.cs
Source:
XmlReader.cs

MoveToContent()를 호출하고 현재 콘텐츠 노드가 시작 태그 또는 빈 요소 태그인지 여부와 찾은 요소의 Name 속성이 지정된 인수와 일치하는지 여부를 테스트합니다.

public:
 virtual bool IsStartElement(System::String ^ name);
public virtual bool IsStartElement (string name);
abstract member IsStartElement : string -> bool
override this.IsStartElement : string -> bool
Public Overridable Function IsStartElement (name As String) As Boolean

매개 변수

name
String

찾은 요소의 Name 속성과 일치하는 문자열입니다.

반환

테스트한 결과 현재 노드가 요소이고 true 속성이 지정된 문자열과 일치하면 Name이고, false 이외의 노드 형식을 찾거나 요소 XmlNodeType.Element 속성이 지정된 문자열과 일치하지 않으면 Name입니다.

예외

입력 스트림에 잘못된 XML이 있는 경우

이전 비동기 작업이 완료되기 전에 XmlReader 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

예제

다음 예제에서는 각 가격 요소를 표시합니다.

// Parse the file and display each price node.
while (reader.Read()) {
  if (reader.IsStartElement("price")) {
     Console.WriteLine(reader.ReadInnerXml());
  }
}
' Parse the file and display each price node.
While reader.Read()
  If reader.IsStartElement("price") Then
    Console.WriteLine(reader.ReadInnerXml())
  End If
End While

설명

이 메서드는 판독기가 콘텐츠 노드에 배치될 때까지 공백, 주석 및 처리 지침을 건너뜁니다. 그런 다음 메서드는 현재 노드가 요소인지 테스트합니다.

추가 정보

적용 대상