NameTable Class

Definition

Implements a single-threaded XmlNameTable.

C#
public class NameTable : System.Xml.XmlNameTable
Inheritance
NameTable

Examples

The following example compares two element names.

C#

NameTable nt = new NameTable();
object book = nt.Add("book");
object price = nt.Add("price");

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

reader.MoveToContent();
reader.ReadToDescendant("book");

 if (System.Object.ReferenceEquals(book, reader.Name)) {
     // Do additional processing.
 }

Remarks

Several classes, such as XmlDocument and XmlReader, use the NameTable class internally to store attribute and element names. When an element or attribute name occurs multiple times in an XML document, it is stored only once in the NameTable.

The names are stored as common language runtime (CLR) object types. This enables you to do object comparisons on these strings rather than a more expensive string comparison. These string objects are referred to as atomized strings.

Constructors

NameTable()

Initializes a new instance of the NameTable class.

Methods

Add(Char[], Int32, Int32)

Atomizes the specified string and adds it to the NameTable.

Add(String)

Atomizes the specified string and adds it to the NameTable.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Get(Char[], Int32, Int32)

Gets the atomized string containing the same characters as the specified range of characters in the given array.

Get(String)

Gets the atomized string with the specified value.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Product Versions
.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, 8, 9
.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, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0