XmlElement.RemoveAttributeNode Método

Definição

Remove um XmlAttribute.

Sobrecargas

Name Description
RemoveAttributeNode(XmlAttribute)

Remove o especificado XmlAttribute.

RemoveAttributeNode(String, String)

Remove o XmlAttribute URI especificado pelo nome local e namespace. (Se o atributo removido tiver um valor predefinido, é imediatamente substituído).

RemoveAttributeNode(XmlAttribute)

Origem:
XmlElement.cs
Origem:
XmlElement.cs
Origem:
XmlElement.cs
Origem:
XmlElement.cs
Origem:
XmlElement.cs

Remove o especificado XmlAttribute.

public:
 virtual System::Xml::XmlAttribute ^ RemoveAttributeNode(System::Xml::XmlAttribute ^ oldAttr);
public virtual System.Xml.XmlAttribute RemoveAttributeNode(System.Xml.XmlAttribute oldAttr);
public virtual System.Xml.XmlAttribute? RemoveAttributeNode(System.Xml.XmlAttribute oldAttr);
abstract member RemoveAttributeNode : System.Xml.XmlAttribute -> System.Xml.XmlAttribute
override this.RemoveAttributeNode : System.Xml.XmlAttribute -> System.Xml.XmlAttribute
Public Overridable Function RemoveAttributeNode (oldAttr As XmlAttribute) As XmlAttribute

Parâmetros

oldAttr
XmlAttribute

O XmlAttribute nó a remover. Se o atributo removido tiver um valor por defeito, é imediatamente substituído.

Devoluções

O removido XmlAttribute ou null se oldAttr não é um nó de atributo do XmlElement.

Exceções

Este nó é apenas de leitura.

Aplica-se a

RemoveAttributeNode(String, String)

Origem:
XmlElement.cs
Origem:
XmlElement.cs
Origem:
XmlElement.cs
Origem:
XmlElement.cs
Origem:
XmlElement.cs

Remove o XmlAttribute URI especificado pelo nome local e namespace. (Se o atributo removido tiver um valor predefinido, é imediatamente substituído).

public:
 virtual System::Xml::XmlAttribute ^ RemoveAttributeNode(System::String ^ localName, System::String ^ namespaceURI);
public virtual System.Xml.XmlAttribute RemoveAttributeNode(string localName, string namespaceURI);
public virtual System.Xml.XmlAttribute? RemoveAttributeNode(string localName, string? namespaceURI);
abstract member RemoveAttributeNode : string * string -> System.Xml.XmlAttribute
override this.RemoveAttributeNode : string * string -> System.Xml.XmlAttribute
Public Overridable Function RemoveAttributeNode (localName As String, namespaceURI As String) As XmlAttribute

Parâmetros

localName
String

O nome local do atributo.

namespaceURI
String

O URI do namespace do atributo.

Devoluções

O nó removido XmlAttribute ou null se não XmlElement tiver um atributo correspondente.

Exceções

Este nó é apenas de leitura.

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 xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlElement root = doc.DocumentElement;

    // Remove the ISBN attribute.
    root.RemoveAttributeNode("ISBN", "urn:samples");

    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 xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>")

    Dim root as XmlElement = doc.DocumentElement

    ' Remove the ISBN attribute.
    root.RemoveAttributeNode("ISBN", "urn:samples")
    
    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.InnerXml)

  end sub
end class

Aplica-se a