XmlElement.RemoveAttributeNode Metod

Definition

Tar bort en XmlAttribute.

Överlagringar

Name Description
RemoveAttributeNode(XmlAttribute)

Tar bort den angivna XmlAttribute.

RemoveAttributeNode(String, String)

Tar bort det XmlAttribute som anges av det lokala namnet och namnområdes-URI:n. (Om det borttagna attributet har ett standardvärde ersätts det omedelbart).

RemoveAttributeNode(XmlAttribute)

Källa:
XmlElement.cs
Källa:
XmlElement.cs
Källa:
XmlElement.cs
Källa:
XmlElement.cs
Källa:
XmlElement.cs

Tar bort den angivna 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

Parametrar

oldAttr
XmlAttribute

Noden XmlAttribute som ska tas bort. Om det borttagna attributet har ett standardvärde ersätts det omedelbart.

Returer

Den borttagna XmlAttribute eller null om oldAttr inte är en attributnod för XmlElement.

Undantag

Den här noden är skrivskyddad.

Gäller för

RemoveAttributeNode(String, String)

Källa:
XmlElement.cs
Källa:
XmlElement.cs
Källa:
XmlElement.cs
Källa:
XmlElement.cs
Källa:
XmlElement.cs

Tar bort det XmlAttribute som anges av det lokala namnet och namnområdes-URI:n. (Om det borttagna attributet har ett standardvärde ersätts det omedelbart).

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

Parametrar

localName
String

Attributets lokala namn.

namespaceURI
String

Attributets namnområdes-URI.

Returer

XmlAttribute Borttagen eller null om den XmlElement inte har en matchande attributnod.

Undantag

Den här noden är skrivskyddad.

Exempel

I följande exempel tar du bort ett attribut från ett element.

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

Gäller för