XmlNameTable クラス
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
最小単位に分割された文字列オブジェクトのテーブル。
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 実装されます。
Xml |
XmlNameTable クラスの新しいインスタンスを初期化します。 |
Add(Char[], Int32, Int32) |
派生クラスでオーバーライドされると、指定した文字列を最小単位に分割し、 |
Add(String) |
派生クラスでオーバーライドされると、指定した文字列を最小単位に分割し、 |
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
Get(Char[], Int32, Int32) |
派生クラスでオーバーライドされると、指定した配列内の指定した範囲の文字と同じ文字を含む、最小単位に分割された文字列を取得します。 |
Get(String) |
派生クラスでオーバーライドされると、指定した文字列と同じ値を含む最小単位に分割された文字列を取得します。 |
Get |
既定のハッシュ関数として機能します。 (継承元 Object) |
Get |
現在のインスタンスの Type を取得します。 (継承元 Object) |
Memberwise |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
To |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |