public class XmlNamedNodeMap : IEnumerable
|
| Count | Read-only Gets the number of nodes in the XmlNamedNodeMap. |
| Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
| GetEnumerator | Provides support for the "foreach" style iteration over the collection of nodes in the XmlNamedNodeMap. |
| GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
| GetNamedItem | Overloaded:GetNamedItem(string name) Retrieves an XmlNode specified by name. |
| GetNamedItem | Overloaded:GetNamedItem(string localName, string namespaceURI) Retrieves a node with the matching XmlNode.LocalName and XmlNode.NamespaceURI. |
| GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
| Item | Retrieves the node at the specified index in the XmlNamedNodeMap. |
| RemoveNamedItem | Overloaded:RemoveNamedItem(string name) Removes the node from the XmlNamedNodeMap. |
| RemoveNamedItem | Overloaded:RemoveNamedItem(string localName, string namespaceURI) Removes a node with the matching XmlNode.LocalName and XmlNode.NamespaceURI. |
| SetNamedItem | Adds an XmlNode using its XmlNode.Name property |
| ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
| Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
| MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public virtual int Count {get;}
|
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;
Console.WriteLine("Display all the attributes for this book...");
for (int i=0; i < attrColl.Count; i++)
{
Console.WriteLine("{0} = {1}", attrColl.Item(i).Name, attrColl.Item(i).Value);
}
}
}
~XmlNamedNodeMap(); |
public virtual IEnumerator GetEnumerator(); |
using System;
using System.IO;
using System.Xml;
using System.Collections;
public class Sample
{
public static void Main()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' publicationdate='1997' " +
" ISBN='1-861001-57-5'>" +
" <title>Pride And Prejudice</title>" +
"</book>");
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
Console.WriteLine("Display all the attributes for this book...");
IEnumerator ienum = attrColl.GetEnumerator();
while (ienum.MoveNext())
{
XmlAttribute attr = (XmlAttribute)ienum.Current;
Console.WriteLine("{0} = {1}", attr.Name, attr.Value);
}
}
}
public virtual int GetHashCode(); |
name
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;
//Change the value for the genre attribute.
XmlAttribute attr = (XmlAttribute)attrColl.GetNamedItem("genre");
attr.Value = "fiction";
Console.WriteLine("Display the modified XML...");
Console.WriteLine(doc.OuterXml);
}
}
localName
namespaceURI
public Type GetType(); |
index
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;
Console.WriteLine("Display all the attributes for this book...");
for (int i=0; i < attrColl.Count; i++)
{
Console.WriteLine("{0} = {1}", attrColl.Item(i).Name, attrColl.Item(i).Value);
}
}
}
protected object MemberwiseClone(); |
name
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);
}
}
localName
namespaceURI
node
| Exception Type | Condition |
|---|---|
| ArgumentException | The node was created from a different XmlDocument than the one that created the XmlNamedNodeMap; or the XmlNamedNodeMap is read-only. |
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;
//Add a new attribute to the collection.
XmlAttribute attr = doc.CreateAttribute("style");
attr.Value = "hardcover";
attrColl.SetNamedItem(attr);
Console.WriteLine("Display the modified XML...");
Console.WriteLine(doc.OuterXml);
}
}
public virtual string ToString(); |