2005-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.XML / Mono.Xml.XPath / DTMXPathNavigator2.cs
index 0636811dd754b3d91318cc02c76ccf9442956b91..6280e3d1bbadc69db1194449a23ad45345ff66b8 100755 (executable)
@@ -228,20 +228,32 @@ namespace Mono.Xml.XPath
                                        return nonAtomicStringPool [nodes [currentNode].Value];
                                }
 
-                               // Element
+                               // Element - collect all content values
+                               int iter = nodes [currentNode].FirstChild;
+                               if (iter == 0)
+                                       return String.Empty;
+
                                if (valueBuilder == null)
                                        valueBuilder = new StringBuilder ();
                                else
                                        valueBuilder.Length = 0;
-                               
-                               int iter = nodes [currentNode].FirstChild;
-                               int depth = nodes [currentNode].Depth;
-                               while (iter < nodes.Length && nodes [iter].Depth > depth) {
+
+                               int end = nodes [currentNode].NextSibling;
+                               if (end == 0) {
+                                       int tmp = currentNode;
+                                       do {
+                                               tmp = nodes [tmp].Parent;
+                                               end = nodes [tmp].NextSibling;
+                                       } while (end == 0 && tmp != 0);
+                                       if (end == 0)
+                                               end = nodes.Length;
+                               }
+
+                               while (iter < end) {
                                        switch (nodes [iter].NodeType) {
-                                       case XPathNodeType.Comment:
-                                       case XPathNodeType.ProcessingInstruction:
-                                               break;
-                                       default:
+                                       case XPathNodeType.Text:
+                                       case XPathNodeType.SignificantWhitespace:
+                                       case XPathNodeType.Whitespace:
                                                valueBuilder.Append (nonAtomicStringPool [nodes [iter].Value]);
                                                break;
                                        }