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

注釈

また、内部的にこのクラスを使用して属性名とXmlReader要素名をXmlNameTable格納するクラスなどXmlDocument、いくつかのクラスがあります。 要素名または属性名が 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)

適用対象

こちらもご覧ください