다음을 통해 공유


XmlReader.LocalName 속성

파생 클래스에서 재정의되면 현재 노드의 로컬 이름을 가져옵니다.

네임스페이스: System.Xml
어셈블리: System.Xml(system.xml.dll)

구문

‘선언
Public MustOverride ReadOnly Property LocalName As String
‘사용 방법
Dim instance As XmlReader
Dim value As String

value = instance.LocalName
public abstract string LocalName { get; }
public:
virtual property String^ LocalName {
    String^ get () abstract;
}
/** @property */
public abstract String get_LocalName ()
public abstract function get LocalName () : String

속성 값

접두사를 제거한 현재 노드의 이름입니다. 예를 들어, LocalName<bk:book> 요소에 대한 book입니다. 이름이 없는 노드 형식(예: Text, Comment 등)의 경우 이 속성은 String.Empty를 반환합니다.

예제

다음 예제에서는 각 노드의 로컬 이름과 접두사 및 네임스페이스 URI를 보여 줍니다.

Dim reader As XmlReader = XmlReader.Create("book2.xml")
        
' Parse the file.  If they exist, display the prefix and 
' namespace URI of each node.
While reader.Read()
  If reader.IsStartElement() Then
    If reader.Prefix = String.Empty Then
      Console.WriteLine("<{0}>", reader.LocalName)
    Else
      Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName)
      Console.WriteLine(" The namespace URI is " + reader.NamespaceURI)
    End If
  End If
End While
reader.Close()
XmlReader reader = XmlReader.Create("book2.xml");

// Parse the file.  If they exist, display the prefix and 
// namespace URI of each node.
while (reader.Read()) {
  if (reader.IsStartElement()) {
    if (reader.Prefix==String.Empty)
      Console.WriteLine("<{0}>", reader.LocalName);
    else {
      Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName);
      Console.WriteLine(" The namespace URI is " + reader.NamespaceURI);
    }
  }
}       
reader.Close();

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

<book xmlns:bk='urn:samples'>
  <title>Pride And Prejudice</title>
  <bk:genre>novel</bk:genre>
</book>

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

XmlReader 클래스
XmlReader 멤버
System.Xml 네임스페이스

기타 리소스

XmlReader로 XML 읽기