XmlNameTable Class
Table of atomized string objects.
For a list of all members of this type, see XmlNameTable Members.
System.Object
System.Xml.XmlNameTable
System.Xml.NameTable
[Visual Basic] MustInherit Public Class XmlNameTable [C#] public abstract class XmlNameTable [C++] public __gc __abstract class XmlNameTable [JScript] 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.
Remarks
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.
Example
[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 Console.WriteLine("matches!") end if [C#] //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) Console.WriteLine("matches!"); [C++] //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) Console::WriteLine(S"matches!");
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
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)