XmlElement.RemoveAttributeAt(Int32) Método

Definición

Quita el nodo de atributo con el índice especificado del elemento . (Si el atributo quitado tiene un valor predeterminado, se reemplaza inmediatamente).

public:
 virtual System::Xml::XmlNode ^ RemoveAttributeAt(int i);
public virtual System.Xml.XmlNode RemoveAttributeAt(int i);
abstract member RemoveAttributeAt : int -> System.Xml.XmlNode
override this.RemoveAttributeAt : int -> System.Xml.XmlNode
Public Overridable Function RemoveAttributeAt (i As Integer) As XmlNode

Parámetros

i
Int32

Índice del nodo que se va a quitar. El primer nodo tiene el índice 0.

Devoluciones

El nodo de atributo se ha quitado o null si no hay ningún nodo en el índice especificado.

Ejemplos

En el ejemplo siguiente se quita un atributo de un elemento .

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlElement root = doc.DocumentElement;

    // Remove the genre attribute.
    root.RemoveAttributeAt(0);

    Console.WriteLine("Display the modified XML...");
    Console.WriteLine(doc.InnerXml);
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>")      

    Dim root as XmlElement = doc.DocumentElement

    ' Remove the genre attribute.
    root.RemoveAttributeAt(0)

    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.InnerXml)

  end sub
end class

Comentarios

Este método es una extensión Microsoft al modelo de objetos de documento (DOM).

Se aplica a