XmlNamedNodeMap.RemoveNamedItem 方法

定義

XmlNamedNodeMap 移除指定的節點。

多載

RemoveNamedItem(String)

XmlNamedNodeMap 移除節點。

RemoveNamedItem(String, String)

移除具有符合的 LocalNameNamespaceURI 的節點。

RemoveNamedItem(String)

XmlNamedNodeMap 移除節點。

public:
 virtual System::Xml::XmlNode ^ RemoveNamedItem(System::String ^ name);
public virtual System.Xml.XmlNode RemoveNamedItem (string name);
public virtual System.Xml.XmlNode? RemoveNamedItem (string name);
abstract member RemoveNamedItem : string -> System.Xml.XmlNode
override this.RemoveNamedItem : string -> System.Xml.XmlNode
Public Overridable Function RemoveNamedItem (name As String) As XmlNode

參數

name
String

要移除的節點的限定名稱。 它會與符合節點的 Name 屬性相符。

傳回

XmlNode

從這個 XmlNode 移除 XmlNamedNodeMap;如果找不到符合的節點,則為 null

範例

下列範例會 XmlAttributeCollection 使用繼承自 XmlNamedNodeMap) 的 類別 (來移除屬性。

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book genre='novel' publicationdate='1997'>   <title>Pride And Prejudice</title></book>" );
   XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes;
   
   // Remove the publicationdate attribute.
   attrColl->RemoveNamedItem( "publicationdate" );
   Console::WriteLine( "Display the modified XML..." );
   Console::WriteLine( doc->OuterXml );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml("<book genre='novel' publicationdate='1997'> " +
                 "  <title>Pride And Prejudice</title>" +
                 "</book>");

     XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

     // Remove the publicationdate attribute.
     attrColl.RemoveNamedItem("publicationdate");

     Console.WriteLine("Display the modified XML...");
     Console.WriteLine(doc.OuterXml);
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book genre='novel' publicationdate='1997'> " & _
                "  <title>Pride And Prejudice</title>" & _
                "</book>")
                         
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes

    ' Remove the publicationdate attribute.
    attrColl.RemoveNamedItem("publicationdate")

    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.OuterXml)
    
  end sub
end class

適用於

RemoveNamedItem(String, String)

移除具有符合的 LocalNameNamespaceURI 的節點。

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

參數

localName
String

要移除的節點的區域名稱。

namespaceURI
String

要移除的節點的命名空間 URI。

傳回

XmlNode

移除 XmlNode;如果找不到符合的節點,則為 null

適用於