This documentation is archived and is not being maintained.

NameTable Class

Implements a single-threaded XmlNameTable.

For a list of all members of this type, see NameTable Members.


[Visual Basic]
Public Class NameTable
   Inherits XmlNameTable
public class NameTable : XmlNameTable
public __gc class NameTable : public XmlNameTable
public class NameTable extends XmlNameTable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


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 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 '.


[Visual Basic, C#, C++] The following example compares two element names.

[Visual Basic] 
'Create the reader.
Dim rdr as XmlTextReader = new XmlTextReader("book.xml")

Dim nt as NameTable = new NameTable()
Dim name as String = nt.Add("book")

while (rdr.Read())
end while
if rdr.NameTable.Get("book") is name
end if

//Create the reader.
XmlTextReader rdr = new XmlTextReader("book.xml");

NameTable nt = new NameTable();
String name = nt.Add("book");

while (rdr.Read()){}
if (rdr.NameTable.Get("book") == name)

//Create the reader.
XmlTextReader* rdr = new XmlTextReader(S"book.xml");

NameTable* nt = new NameTable();
String * name = nt -> Add(S"book");

while (rdr -> Read()) {}
if (rdr -> NameTable -> Get(S"book") == name)

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Xml

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Xml (in System.Xml.dll)

See Also

NameTable Members | System.Xml Namespace