XmlNameTable XmlNameTable XmlNameTable XmlNameTable Class

Definición

Tabla de objetos en forma de cadena subdividida.Table of atomized string objects.

public ref class XmlNameTable abstract
public abstract class XmlNameTable
type XmlNameTable = class
Public MustInherit Class XmlNameTable
Herencia
XmlNameTableXmlNameTableXmlNameTableXmlNameTable
Derivado

Ejemplos

En el ejemplo siguiente se compara dos nombres de elemento.The following example compares two element names.


// Add the element names to the NameTable.
NameTable nt = new NameTable();
object book = nt.Add("book");
object title = nt.Add("title");

 // Create a reader that uses the NameTable.
 XmlReaderSettings settings = new XmlReaderSettings();
 settings.NameTable = nt;
 XmlReader reader = XmlReader.Create("books.xml", settings);

 while (reader.Read()) {
    if (reader.NodeType == XmlNodeType.Element) {
      // Cache the local name to prevent multiple calls to the LocalName property.
      object localname = reader.LocalName;

      // Do a comparison between the object references. This just compares pointers.
      if (book == localname) {
          // Add additional processing here.
      }
      // Do a comparison between the object references. This just compares pointers.
      if (title == localname) {
         // Add additional processing here.
      }
         
    } 

 }  // End While

// Close the reader.
reader.Close();     

' Add the element names to the NameTable.
Dim nt As New NameTable()
Dim book As Object = nt.Add("book")
Dim title As Object = nt.Add("title")

' Create a reader that uses the NameTable.
Dim settings As New XmlReaderSettings()
settings.NameTable = nt
Dim reader As XmlReader = XmlReader.Create("books.xml", settings)

While reader.Read()
    If reader.NodeType = XmlNodeType.Element Then
        ' Cache the local name to prevent multiple calls to the LocalName property.
        Dim localname As Object = reader.LocalName
        
        ' Do a comparison between the object references. This just compares pointers.
        If book Is localname Then
           ' Add additional processing here.
        End If 
        ' Do a comparison between the object references. This just compares pointers.
        If title Is localname Then
           ' Add additional processing here.
        End If 
    End If
End While 

' Close the reader.
reader.Close()

Comentarios

Varias clases, como XmlDocument y XmlReader, utilice el XmlNameTable clase internamente para almacenar los nombres de atributo y elemento.Several classes, such as XmlDocument and XmlReader, use the XmlNameTable class internally to store attribute and element names. Cuando un nombre de atributo o elemento aparece varias veces en un documento XML, se almacena en XmlNameTable sólo una vez.When an element or attribute name occurs multiple times in an XML document, it is stored only once in the XmlNameTable.

Los nombres se almacenan como tipos de objetos de Common Language Runtime (CLR).The names are stored as common language runtime (CLR) object types. Esto permite comparar objetos en estas cadenas en lugar de comparar cadenas, que consume más recursos.This enables you to do object comparisons on these strings rather than a more expensive string comparison. Estos objetos de cadena se conocen como "cadenas subdivididas".These string objects are referred to as "atomized strings".

XmlNameTable se implementa en el NameTable clase.XmlNameTable is implemented in the NameTable class.

Constructores

XmlNameTable() XmlNameTable() XmlNameTable() XmlNameTable()

Inicializa una nueva instancia de la clase XmlNameTable.Initializes a new instance of the XmlNameTable class.

Métodos

Add(Char[], Int32, Int32) Add(Char[], Int32, Int32) Add(Char[], Int32, Int32) Add(Char[], Int32, Int32)

Cuando se invalida en una clase derivada, subdivide la cadena especificada y la agrega a XmlNameTable.When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.

Add(String) Add(String) Add(String) Add(String)

Cuando se invalida en una clase derivada, subdivide la cadena especificada y la agrega a XmlNameTable.When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Get(Char[], Int32, Int32) Get(Char[], Int32, Int32) Get(Char[], Int32, Int32) Get(Char[], Int32, Int32)

Cuando se invalida en una clase derivada, se obtiene la cadena subdividida que contiene los mismos caracteres que el intervalo de caracteres especificado en una matriz determinada.When overridden in a derived class, gets the atomized string containing the same characters as the specified range of characters in the given array.

Get(String) Get(String) Get(String) Get(String)

Cuando se invalida en una clase derivada, obtiene la cadena subdividida que contiene el mismo valor que la cadena especificada.When overridden in a derived class, gets the atomized string containing the same value as the specified string.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a

Consulte también: