Ανάγνωση στα Αγγλικά Επεξεργασία

Κοινή χρήση μέσω


XmlNamedNodeMap.RemoveNamedItem Method

Definition

Removes the specified node from the XmlNamedNodeMap.

Overloads

RemoveNamedItem(String)

Removes the node from the XmlNamedNodeMap.

RemoveNamedItem(String, String)

Removes a node with the matching LocalName and NamespaceURI.

RemoveNamedItem(String)

Source:
XmlNamedNodemap.cs
Source:
XmlNamedNodemap.cs
Source:
XmlNamedNodemap.cs

Removes the node from the XmlNamedNodeMap.

public virtual System.Xml.XmlNode RemoveNamedItem (string name);
public virtual System.Xml.XmlNode? RemoveNamedItem (string name);

Parameters

name
String

The qualified name of the node to remove. The name is matched against the Name property of the matching node.

Returns

The XmlNode removed from this XmlNamedNodeMap or null if a matching node was not found.

Examples

The following example uses the XmlAttributeCollection class (which inherits from XmlNamedNodeMap) to remove an attribute.

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);
  }
}

Applies to

.NET 9 και άλλες εκδόσεις
Προϊόν Εκδόσεις
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

RemoveNamedItem(String, String)

Source:
XmlNamedNodemap.cs
Source:
XmlNamedNodemap.cs
Source:
XmlNamedNodemap.cs

Removes a node with the matching LocalName and NamespaceURI.

public virtual System.Xml.XmlNode RemoveNamedItem (string localName, string namespaceURI);
public virtual System.Xml.XmlNode? RemoveNamedItem (string localName, string? namespaceURI);

Parameters

localName
String

The local name of the node to remove.

namespaceURI
String

The namespace URI of the node to remove.

Returns

The XmlNode removed or null if a matching node was not found.

Applies to

.NET 9 και άλλες εκδόσεις
Προϊόν Εκδόσεις
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0