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
。