This documentation is archived and is not being maintained.

XmlNameTable Class

Table of atomized string objects.

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


[Visual Basic]
MustInherit Public Class XmlNameTable
public abstract class XmlNameTable
public __gc __abstract class XmlNameTable
public abstract class 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 XmlNameTable 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 XmlNameTable.

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

XmlNameTable is implemented in the NameTable class.


[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

XmlNameTable Members | System.Xml Namespace | NameTable