2003-02-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml / XmlLinkedNode.cs
index 090bedcf6b924e0235ad7635a195c3284cbbc1e3..cc6be542fd446b6cd69324dfa922a9fbb33b7789 100644 (file)
@@ -7,7 +7,7 @@
 //
 // (C) 2002 Jason Diamond, Kral Ferch
 //
-\r
+
 using System;
 
 namespace System.Xml
@@ -17,6 +17,7 @@ namespace System.Xml
                #region Fields
 
                XmlLinkedNode nextSibling;
+               XmlLinkedNode lastLinkedChild;
 
                #endregion
 
@@ -30,7 +31,10 @@ namespace System.Xml
                public override XmlNode NextSibling
                {
                        get {
-                               if (Object.ReferenceEquals(nextSibling, ParentNode.LastLinkedChild.NextLinkedSibling) == false) {
+                               if(ParentNode == null) {
+                                       return null;
+                               }
+                               else if (Object.ReferenceEquals(nextSibling, ParentNode.LastLinkedChild.NextLinkedSibling) == false) {
                                        return nextSibling;
                                }
                                else {
@@ -61,6 +65,13 @@ namespace System.Xml
                        }
                }
 
+               // copied this way from XmlElement
+               internal override XmlLinkedNode LastLinkedChild
+               {
+                       get { return lastLinkedChild; }
+                       set { lastLinkedChild = value; }
+               }
+
                #endregion
        }
 }