[Mono-bugs] [Bug 78067][Nor] New - Cannot write out simple XML file using XPathNavigator

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Apr 10 04:14:38 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jwiegley at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78067

--- shadow/78067	2006-04-10 04:14:38.000000000 -0400
+++ shadow/78067.tmp.25004	2006-04-10 04:14:38.000000000 -0400
@@ -0,0 +1,78 @@
+Bug#: 78067
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 10.4.5, Mono 1.1.13.6
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: jwiegley at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Cannot write out simple XML file using XPathNavigator
+
+My apologies if I'm missing something basic, but after a couple hours of web searching, I am 
+unable to see what's wrong with this example.  I have the following data in "file.xml":
+
+<?xml version="1.0"?>
+<one>
+	<two>Some data.</two>
+</one>
+
+And I have this test program:
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace Test
+{
+	public class MyTest
+	{
+		public static int Main(string[] args)
+		{
+			XPathDocument doc = new XPathDocument(args[0]);
+			XPathNavigator nav = doc.CreateNavigator();
+			//nav.MoveToRoot();    // this makes no difference
+			Console.Write(nav.OuterXml);
+			return 0;
+		}
+	}
+}
+
+According to what I've read, this should output the XML data.  And if there is no embedded 
+<two> tag, this is just what it does.  But once I have any nested tags, it gives me an exception:
+
+~ $ mono --debug test.exe file.xml
+
+Unhandled Exception: System.InvalidOperationException: There was no XML start tag open.
+in [0x001c6] System.Xml.XmlTextWriter:WriteEndElementInternal (Boolean fullEndElement)
+in [0x00002] (at /private/tmp/scratch/mono-1.1.13.6/mcs/class/System.XML/System.Xml/
+XmlTextWriter.cs:683) System.Xml.XmlTextWriter:WriteFullEndElement ()
+in [0x00123] (at /private/tmp/scratch/mono-1.1.13.6/mcs/class/System.XML/System.Xml/
+XmlWriter.cs:491) System.Xml.XmlWriter:WriteNode (System.Xml.XmlReader reader, Boolean 
+defattr)
+in [0x00022] (at /private/tmp/scratch/mono-1.1.13.6/mcs/class/System.XML/System.Xml/
+XmlWriter.cs:457) System.Xml.XmlWriter:WriteNode (System.Xml.XmlReader reader, Boolean 
+defattr)
+in [0x000ea] (at /private/tmp/scratch/mono-1.1.13.6/mcs/class/System.XML/System.Xml/
+XmlWriter.cs:443) System.Xml.XmlWriter:WriteNode (System.Xml.XPath.XPathNavigator navigator, 
+Boolean defattr)
+in [0x00003] (at /private/tmp/scratch/mono-1.1.13.6/mcs/class/System.XML/
+System.Xml.XPath/XPathNavigator.cs:874) System.Xml.XPath.XPathNavigator:WriteSubtree 
+(System.Xml.XmlWriter writer)
+in [0x0000f] (at /private/tmp/scratch/mono-1.1.13.6/mcs/class/System.XML/
+System.Xml.XPath/XPathNavigator.cs:913) System.Xml.XPath.XPathNavigator:get_OuterXml ()
+in [0x00011] (at /Users/johnw/Contracts/spider/test.cs:15) Test.MyTest:Main (System.String[] 
+args)
+
+I've combed through XmlWriter.cs and friends, but nothing jumps out at me.  Either I'm doing 
+something very wrong, or there's indeed a reason to trouble your inbox.  Btw, I derived this code 
+from examples in the .NET documentation.
+
+John


More information about the mono-bugs mailing list