XmlNameTable クラス

定義

アトミック化された文字列オブジェクトの表。

public ref class XmlNameTable abstract
public abstract class XmlNameTable
type XmlNameTable = class
Public MustInherit Class XmlNameTable
継承
XmlNameTable
派生

次の例では、2 つの要素名を比較します。


// 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()

注釈

XmlDocumentXmlReaderなど、いくつかのクラスでは、XmlNameTable クラスを内部的に使用して属性と要素の名前を格納します。 XML ドキュメント内で要素または属性名が複数回発生した場合、その名前は XmlNameTableに 1 回だけ格納されます。

名前は、共通言語ランタイム (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)

適用対象

こちらもご覧ください