NameTable Class
Implements a single-threaded XmlNameTable.
Assembly: System.Xml (in System.Xml.dll)
The NameTable type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() ![]() | Add(String) | Atomizes the specified string and adds it to the NameTable. (Overrides XmlNameTable::Add(String).) |
![]() ![]() ![]() | Add(array<Char>, Int32, Int32) | Atomizes the specified string and adds it to the NameTable. (Overrides XmlNameTable::Add(array<Char>, Int32, Int32).) |
![]() ![]() ![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() ![]() | Get(String) | Gets the atomized string with the specified value. (Overrides XmlNameTable::Get(String).) |
![]() ![]() ![]() | Get(array<Char>, Int32, Int32) | Gets the atomized string containing the same characters as the specified range of characters in the given array. (Overrides XmlNameTable::Get(array<Char>, Int32, Int32).) |
![]() ![]() ![]() | GetHashCode | Serves as a hash function for a particular type. (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.) |
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.
The following example compares two element names.
NameTable^ nt = gcnew NameTable; Object^ book = nt->Add( "book" ); Object^ price = nt->Add( "price" ); // Create the reader. XmlReaderSettings ^ settings = gcnew XmlReaderSettings; settings->NameTable = nt; XmlReader^ reader = XmlReader::Create( (String^)"books.xml", settings ); reader->MoveToContent(); reader->ReadToDescendant( "book" ); if ( System::Object::ReferenceEquals( book, reader->Name ) ) { // Do additional processing. }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

