Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
RemoveNamedItem Method (String)
Collapse the table of content
Expand the table of content

XmlNamedNodeMap.RemoveNamedItem Method (String)

Removes the node from the XmlNamedNodeMap.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public virtual XmlNode RemoveNamedItem(
	string name
)

Parameters

name
Type: System.String

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

Return Value

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

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

  }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft