* Implemented ReadInnerXml and ReadOuterXml. We still need to validate for
[mono.git] / mcs / class / System.XML / System.Xml / XmlNode.cs
index 851c0115629e3aeab84c14d4a40067f2ad82285f..87fbc8aa2141ed642b2509944ac385a8a9fa5a73 100644 (file)
@@ -9,6 +9,7 @@
 
 using System;
 using System.Collections;
+using System.IO;
 using System.Xml.XPath;
 
 namespace System.Xml
@@ -24,7 +25,7 @@ namespace System.Xml
 
                #region Constructors
 
-               protected internal XmlNode(XmlDocument ownerDocument)
+               internal XmlNode (XmlDocument ownerDocument)
                {
                        this.ownerDocument = ownerDocument;
                }
@@ -71,9 +72,17 @@ namespace System.Xml
                        set { throw new NotImplementedException (); }
                }
 
-               [MonoTODO]
+               [MonoTODO("Setter.")]
                public virtual string InnerXml {
-                       get { throw new NotImplementedException (); }
+                       get {
+                               StringWriter sw = new StringWriter ();
+                               XmlTextWriter xtw = new XmlTextWriter (sw);
+
+                               WriteContentTo(xtw);
+
+                               return sw.GetStringBuilder().ToString();
+                       }
+
                        set { throw new NotImplementedException (); }
                }
 
@@ -134,9 +143,15 @@ namespace System.Xml
 
                public abstract XmlNodeType NodeType { get;     }
 
-               [MonoTODO]
                public virtual string OuterXml {
-                       get { throw new NotImplementedException (); }
+                       get {
+                               StringWriter sw = new StringWriter ();
+                               XmlTextWriter xtw = new XmlTextWriter (sw);
+
+                               WriteTo(xtw);
+
+                               return sw.GetStringBuilder().ToString();
+                       }
                }
 
                public virtual XmlDocument OwnerDocument {
@@ -157,10 +172,9 @@ namespace System.Xml
                        get { return null; }
                }
 
-               [MonoTODO]
                public virtual string Value {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return null; }
+                       set { throw new InvalidOperationException ("This node does not have a value"); }
                }
 
                #endregion
@@ -169,9 +183,13 @@ namespace System.Xml
 
                public virtual XmlNode AppendChild (XmlNode newChild)
                {
-                       if (NodeType == XmlNodeType.Document || NodeType == XmlNodeType.Element || NodeType == XmlNodeType.Attribute) {
-                               XmlLinkedNode newLinkedChild = (XmlLinkedNode)newChild;
+                       if (NodeType == XmlNodeType.Document
+                           || NodeType == XmlNodeType.Element
+                           || NodeType == XmlNodeType.Attribute) {
+                               XmlLinkedNode newLinkedChild = (XmlLinkedNode) newChild;
                                XmlLinkedNode lastLinkedChild = LastLinkedChild;
+
+                               newLinkedChild.parentNode = this;
                                
                                if (lastLinkedChild != null) {
                                        newLinkedChild.NextLinkedSibling = lastLinkedChild.NextLinkedSibling;
@@ -292,25 +310,25 @@ namespace System.Xml
                }
 
                [MonoTODO]
-               public virtual XmlNodeList SelectNodes (string xpath)
+               public XmlNodeList SelectNodes (string xpath)
                {
                        throw new NotImplementedException ();
                }
 
                [MonoTODO]
-               public virtual XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
+               public XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
                {
                        throw new NotImplementedException ();
                }
 
                [MonoTODO]
-               public virtual XmlNode SelectSingleNode (string xpath)
+               public XmlNode SelectSingleNode (string xpath)
                {
                        throw new NotImplementedException ();
                }
 
                [MonoTODO]
-               public virtual XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
+               public XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
                {
                        throw new NotImplementedException ();
                }