XmlNamedNodeMap.RemoveNamedItem 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從 XmlNamedNodeMap
移除指定的節點。
多載
RemoveNamedItem(String) |
從 |
RemoveNamedItem(String, String) |
移除具有符合的 LocalName 和 NamespaceURI 的節點。 |
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
參數
傳回
從這個 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)
移除具有符合的 LocalName 和 NamespaceURI 的節點。
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;如果找不到符合的節點,則為 null
。