[Mono-list] Incompatibility in MONO SelectNodes method
lluis at ximian.com
Sat Dec 1 22:14:15 EST 2007
El dg 02 de 12 del 2007 a les 03:29 +0100, en/na Robert Jordan va
> Andrus wrote:
> > In bug #343960
> > https://bugzilla.novell.com/show_bug.cgi?id=343960
> > I presented code which works OK in .NET but crashes in MONO 1.2.6 pvw2.
> > Probably SelectNodes() in .NET creates new list but in MONO it does not.
> > Atsushi refuses to fix this and marks it INVALID several times.
> He explained pretty well why he refused to fix it.
> > This is fundamental incompatibility between .NET and MONO XML DOM
> > implementation.
MSDN documentation on XmlNodeList:
"The XmlNodeList collection is "live"; that is, changes to the children
of the node object that it was created from are immediately reflected in
the nodes returned by the XmlNodeList properties and methods"
Which means that if you start iterating on an XmlNodeList and a node
included in the list is removed from the parent, the XmlNodeList you are
iterating on will change, so you will get an exception if you continue
iterating. That's how iterators work.
MSDN documentation on SelectNodes():
"The XmlNodeList should not be expected to be connected "live" to the
So while an XmlNodeList returned by ChildNodes will always be "live",
returned by SelectNodes *may* or *may not* be live. For your specific
test case, in Mono the collection is live, in .NET it is not, and both
behaviors are correct according to the documentation.
So it is not a bug on .NET or Mono, it is a bug in your code.
More information about the Mono-list