語言

XmlElement.RemoveAttributeNode 方法

定義

移除一個 XmlAttribute.

多載

名稱 Description
RemoveAttributeNode(XmlAttribute)

移除指定的 XmlAttribute。

RemoveAttributeNode(String, String)

移除由本地名稱和命名空間 URI 所指定的部分 XmlAttribute 。 (若移除的屬性有預設值,則會立即替換。)

RemoveAttributeNode(XmlAttribute)

來源:
XmlElement.cs
來源:
XmlElement.cs
來源:
XmlElement.cs
來源:
XmlElement.cs
來源:
XmlElement.cs

移除指定的 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

參數

oldAttr
XmlAttribute

XmlAttribute要移除的節點。 如果被移除的屬性有預設值,則會立即替換。

傳回

移除 XmlAttribute 的 或 null 如果 oldAttr 不是 的 XmlElement屬性節點。

例外狀況

此節點為唯讀。

適用於

RemoveAttributeNode(String, String)

來源:
XmlElement.cs
來源:
XmlElement.cs
來源:
XmlElement.cs
來源:
XmlElement.cs
來源:
XmlElement.cs

移除由本地名稱和命名空間 URI 所指定的部分 XmlAttribute 。 (若移除的屬性有預設值,則會立即替換。)

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

參數

localName
String

該屬性的當地名稱。

namespaceURI
String

屬性的命名空間 URI。

傳回

移除 XmlAttribute 或 null 如果沒有 XmlElement 匹配的屬性節點。

例外狀況

此節點為唯讀。

範例

以下範例是從一個元素中移除一個屬性。

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

適用於