2 // System.Xml.XmlNamedNodeMap
5 // Jason Diamond (jason@injektilo.org)
6 // Duncan Mak (duncan@ximian.com)
8 // (C) 2002 Jason Diamond http://injektilo.org/
12 using System.Collections;
16 public class XmlNamedNodeMap : IEnumerable
20 bool readOnly = false;
22 internal XmlNamedNodeMap (XmlNode parent)
25 nodeList = new ArrayList ();
28 public virtual int Count {
29 get { return nodeList.Count; }
32 public virtual IEnumerator GetEnumerator ()
34 return nodeList.GetEnumerator ();
37 public virtual XmlNode GetNamedItem (string name)
39 foreach (XmlNode node in nodeList) {
40 if (node.Name == name)
46 public virtual XmlNode GetNamedItem (string localName, string namespaceURI)
48 foreach (XmlNode node in nodeList) {
49 if ((node.LocalName == localName)
50 && (node.NamespaceURI == namespaceURI))
57 public virtual XmlNode Item (int index)
59 if (index < 0 || index > nodeList.Count)
62 return (XmlNode) nodeList [index];
65 public virtual XmlNode RemoveNamedItem (string name)
67 foreach (XmlNode node in nodeList)
68 if (node.Name == name) {
69 nodeList.Remove (node);
76 public virtual XmlNode RemoveNamedItem (string localName, string namespaceURI)
78 foreach (XmlNode node in nodeList)
79 if ((node.LocalName == localName)
80 && (node.NamespaceURI == namespaceURI)) {
81 nodeList.Remove (node);
88 public virtual XmlNode SetNamedItem (XmlNode node)
90 if (readOnly || (node.OwnerDocument != parent.OwnerDocument))
91 throw new ArgumentException ("Cannot add to NodeMap.");
93 foreach (XmlNode x in nodeList)
94 if (x.Name == node.Name) {
104 internal ArrayList Nodes { get { return nodeList; } }