System.Xml.XmlNameTable Class

Assembly: System.Xml.dll
Namespace: System.Xml
Summary
Table of atomized string objects.
C# Syntax:
public abstract class XmlNameTable
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 ' atomizedstrings '.

XmlNameTable is implemented in the NameTable class.

Example
The following example compares two element names.
    //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!");

    
See also:
System.Xml Namespace | NameTable

System.Xml.XmlNameTable Member List:

Public Methods
Add Overloaded:
Add(string array)

When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable. For more information on atomized strings, see XmlNameTable.
Add Overloaded:
Add(char[] array, int offset, int length)

When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable. For more information on atomized strings, see XmlNameTable.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
Get Overloaded:
Get(string array)

When overridden in a derived class, gets the atomized string containing the same value as the specified string. For more information on atomized strings, see XmlNameTable.
Get Overloaded:
Get(char[] array, int offset, int length)

When overridden in a derived class, gets the atomized string containing the same characters as the specified range of characters in the given array. For more information on atomized strings, see XmlNameTable.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Xml.XmlNameTable Member Details

ctor #1
Summary:
Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
protected XmlNameTable();

Return to top


Overloaded Method: Add(
   string array
)
Summary
When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.

For more information on atomized strings, see XmlNameTable.

C# Syntax:
public abstract string Add(
   string array
);
Parameters:

array

The name to add.

Return Value:
The new atomized string or the existing one if it already exists.

Return to top


Overloaded Method: Add(
   char[] array,
   int offset,
   int length
)
Summary
When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.

For more information on atomized strings, see XmlNameTable.

C# Syntax:
public abstract string Add(
   char[] array,
   int offset,
   int length
);
Parameters:

array

The character array containing the name to add.

offset

Zero based index into the array specifying the first character of the name.

length

The number of characters in the name.

Return Value:
The new atomized string or the existing one if it already exists. If length is zero, String.Empty is returned.
Exceptions
Exception Type Condition
IndexOutOfRangeException If 0 > offset >= array.Length or 0 > length >= array.Length - offset.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~XmlNameTable();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: Get(
   string array
)
Summary
When overridden in a derived class, gets the atomized string containing the same value as the specified string.

For more information on atomized strings, see XmlNameTable.

C# Syntax:
public abstract string Get(
   string array
);
Parameters:

array

The name to look up.

Return Value:
The atomized string or null if the string has not already been atomized.

Return to top


Overloaded Method: Get(
   char[] array,
   int offset,
   int length
)
Summary
When overridden in a derived class, gets the atomized string containing the same characters as the specified range of characters in the given array.

For more information on atomized strings, see XmlNameTable.

C# Syntax:
public abstract string Get(
   char[] array,
   int offset,
   int length
);
Parameters:

array

The character array containing the name to look up.

offset

The zero-based index into the array specifying the first character of the name.

length

The number of characters in the name.

Return Value:
The atomized string or null if the string has not already been atomized. If length is zero, String.Empty is returned.
Exceptions
Exception Type Condition
IndexOutOfRangeException If 0 > offset >= array.Length or 0 > length >= array.Length - offset.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.