XmlNameTable 클래스

정의

원자화된 문자열 개체의 테이블입니다.

public ref class XmlNameTable abstract
public abstract class XmlNameTable
type XmlNameTable = class
Public MustInherit Class XmlNameTable
상속
XmlNameTable
파생

예제

다음 예제에서는 두 요소 이름을 비교합니다.


// Add the element names to the NameTable.
NameTable nt = new NameTable();
object book = nt.Add("book");
object title = nt.Add("title");

 // Create a reader that uses the NameTable.
 XmlReaderSettings settings = new XmlReaderSettings();
 settings.NameTable = nt;
 XmlReader reader = XmlReader.Create("books.xml", settings);

 while (reader.Read()) {
    if (reader.NodeType == XmlNodeType.Element) {
      // Cache the local name to prevent multiple calls to the LocalName property.
      object localname = reader.LocalName;

      // Do a comparison between the object references. This just compares pointers.
      if (book == localname) {
          // Add additional processing here.
      }
      // Do a comparison between the object references. This just compares pointers.
      if (title == localname) {
         // Add additional processing here.
      }
    }
 }  // End While

// Close the reader.
reader.Close();
' Add the element names to the NameTable.
Dim nt As New NameTable()
Dim book As Object = nt.Add("book")
Dim title As Object = nt.Add("title")

' Create a reader that uses the NameTable.
Dim settings As New XmlReaderSettings()
settings.NameTable = nt
Dim reader As XmlReader = XmlReader.Create("books.xml", settings)

While reader.Read()
    If reader.NodeType = XmlNodeType.Element Then
        ' Cache the local name to prevent multiple calls to the LocalName property.
        Dim localname As Object = reader.LocalName
        
        ' Do a comparison between the object references. This just compares pointers.
        If book Is localname Then
           ' Add additional processing here.
        End If 
        ' Do a comparison between the object references. This just compares pointers.
        If title Is localname Then
           ' Add additional processing here.
        End If 
    End If
End While 

' Close the reader.
reader.Close()

설명

클래스와 같은 XmlDocument XmlReader여러 클래스는 내부적으로 클래스를 XmlNameTable 사용하여 특성 및 요소 이름을 저장합니다. XML 문서에서 요소나 특성 이름이 여러 번 나오더라도 XmlNameTable에는 한 번만 저장되며,

이름은 CLR(공용 언어 런타임) 개체 형식으로 저장됩니다. 따라서 비용이 많이 드는 문자열 비교를 수행하지 않고도 이 문자열에 대해 개체 비교를 수행할 수 있습니다. 이러한 문자열 개체를 "원자화된 문자열"이라고 합니다.

XmlNameTable 는 클래스에서 NameTable 구현됩니다.

생성자

XmlNameTable()

XmlNameTable 클래스의 새 인스턴스를 초기화합니다.

메서드

Add(Char[], Int32, Int32)

파생 클래스에서 재정의할 경우 지정한 문자열을 원자화하여 이를 XmlNameTable에 추가합니다.

Add(String)

파생 클래스에서 재정의할 경우 지정한 문자열을 원자화하여 이를 XmlNameTable에 추가합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
Get(Char[], Int32, Int32)

파생 클래스에서 재정의할 경우 지정된 배열에 있는 지정된 범위의 문자와 같은 문자를 포함하는 원자화된 문자열을 가져옵니다.

Get(String)

파생 클래스에서 재정의할 경우 지정된 문자열과 같은 값을 포함하는 원자화된 문자열을 가져옵니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보