Bug 4690 - XNodeNavigator.MoveToRoot() stays on self
Summary: XNodeNavigator.MoveToRoot() stays on self
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-04-27 08:49 UTC by eb1
Modified: 2012-05-14 03:32 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Unit test that demonstrates the problem (1.27 KB, patch)
2012-04-27 09:01 UTC, eb1
Suggested fix (1.00 KB, patch)
2012-04-27 09:01 UTC, eb1

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description eb1 2012-04-27 08:49:44 UTC
Consider the following code snippet:

 string data = "<root><parent><child/></parent></root>";
 XElement doc = XElement.Parse (data);
 var iterator = doc.CreateNavigator ().Select ("//child");
 iterator.MoveNext ();
 var element = iterator.Current;
 element.MoveToRoot ();
 Console.WriteLine (element.Name);

Expected output:

Actual output:

This behavior also causes XPathSelectElements() to skip some nodes. It works when we use a XDocument instead of XElement:
 XDocument doc = XDocument.Parse (data);
Comment 1 eb1 2012-04-27 09:01:11 UTC
Created attachment 1760 [details]
Unit test that demonstrates the problem
Comment 2 eb1 2012-04-27 09:01:30 UTC
Created attachment 1761 [details]
Suggested fix
Comment 3 Atsushi Eno 2012-05-14 03:32:55 UTC
This fix is also applied. Thanks again!