XmlElement.RemoveAttributeAt(Int32) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Remove o nó de atributo com o índice especificado do elemento. (Se o atributo removido tiver um valor predefinido, é imediatamente substituído).
public:
virtual System::Xml::XmlNode ^ RemoveAttributeAt(int i);
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
O índice do nó a remover. O primeiro nó tem índice 0.
Devoluções
O nó de atributo removido ou null se não houver nó no índice indicado.
Exemplos
O exemplo seguinte remove um atributo de um 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
Observações
Este método é uma extensão da Microsoft para o Document Object Model (DOM).