XmlElement.RemoveAttributeNode XmlElement.RemoveAttributeNode XmlElement.RemoveAttributeNode XmlElement.RemoveAttributeNode Method

定義

移除 XmlAttributeRemoves an XmlAttribute.

多載

RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute)

移除指定的 XmlAttributeRemoves the specified XmlAttribute.

RemoveAttributeNode(String, String) RemoveAttributeNode(String, String) RemoveAttributeNode(String, String) RemoveAttributeNode(String, String)

移除區域名稱和命名空間 URI 指定的 XmlAttributeRemoves the XmlAttribute specified by the local name and namespace URI. (如果移除的屬性具有預設值,會立即被取代)。(If the removed attribute has a default value, it is immediately replaced).

RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute)

移除指定的 XmlAttributeRemoves the specified XmlAttribute.

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 XmlAttribute

要移除的 XmlAttribute 節點。The XmlAttribute node to remove. 如果移除的屬性具預設值,會立即被取代。If the removed attribute has a default value, it is immediately replaced.

傳回

移除的 XmlAttribute;如果 oldAttr 不是 null 的屬性節點,則為 XmlElementThe removed XmlAttribute or null if oldAttr is not an attribute node of the XmlElement.

例外狀況

這個節點是唯讀的。This node is read-only.

RemoveAttributeNode(String, String) RemoveAttributeNode(String, String) RemoveAttributeNode(String, String) RemoveAttributeNode(String, String)

移除區域名稱和命名空間 URI 指定的 XmlAttributeRemoves the XmlAttribute specified by the local name and namespace URI. (如果移除的屬性具有預設值,會立即被取代)。(If the removed attribute has a default value, it is immediately replaced).

public:
 virtual System::Xml::XmlAttribute ^ RemoveAttributeNode(System::String ^ localName, System::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 String String String

屬性的本機名稱。The local name of the attribute.

namespaceURI
String String String String

屬性的命名空間 URI。The namespace URI of the attribute.

傳回

移除的 XmlAttribute;如果 null 沒有相符的屬性節點,則為 XmlElementThe removed XmlAttribute or null if the XmlElement does not have a matching attribute node.

例外狀況

這個節點是唯讀的。This node is read-only.

範例

下列範例會從元素移除屬性。The following example removes an attribute from an element.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew 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 );
}

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

適用於