2003-02-28 Alan Tam <Tam@SiuLung.com>
[mono.git] / mcs / class / System.XML / System.Xml / XmlNamedNodeMap.cs
index c605a82cb34ec2eaa3e1fbf3f5dcd365001f8c5a..756b30d18b6e0206f0675580e57f21a7de408658 100644 (file)
@@ -86,19 +86,29 @@ namespace System.Xml
                }
 
                public virtual XmlNode SetNamedItem (XmlNode node)
+               {
+                       return SetNamedItem(node, -1);
+               }
+
+               internal XmlNode SetNamedItem (XmlNode node, int pos)
                {
                        if (readOnly || (node.OwnerDocument != parent.OwnerDocument))
                                throw new ArgumentException ("Cannot add to NodeMap.");
-                                               
+
                        foreach (XmlNode x in nodeList)
-                               if (x.Name == node.Name) {
+                               if(x.LocalName == node.LocalName && x.NamespaceURI == node.NamespaceURI) {
                                        nodeList.Remove (x);
                                        nodeList.Add (node);
                                        return x;
                                }
                        
-                       nodeList.Add (node);
+                       if(pos < 0)
+                               nodeList.Add (node);
+                       else
+                               nodeList.Insert(pos, node);
                        return null;
                }
+
+               internal ArrayList Nodes { get { return nodeList; } }
        }
 }