Export (0) Print
Expand All

NameTable Class

Implements a single-threaded XmlNameTable.

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

System.Object
   System.Xml.XmlNameTable
      System.Xml.NameTable

[Visual Basic]
Public Class NameTable
   Inherits XmlNameTable
[C#]
public class NameTable : XmlNameTable
[C++]
public __gc class NameTable : public XmlNameTable
[JScript]
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.

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

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 Language Filter 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)

See Also

NameTable Members | System.Xml Namespace

Show:
© 2014 Microsoft