"Oleg Tkachenko [MVP]" <so**@body.com> wrote in message news:uc**************@TK2MSFTNGP10.phx.gbl...
Hmmm, really. I always thought looping until EOF is necessary because XML can contain comments and PIs before root element, but it
seems to be working without looping just fine too.
Reason being that ReadState.Initial is tantamount to being at the proverbial
"root" of the document as XPath defines it (where the root is essentially in
outer space as far as the document element is concerned). ReadState.EOF
happens only after the Read( ) that produced the XmlNodeType.EndElement
of the document element. Therefore, it too is conceptually beyond the end
of the document. Taken altogether, all XmlDecls, Comments, PIs, etc.,
that exist outside of the document element node are still contained by
the "root." :-)
Yes, if any Read( ) has already ventured into the document then the loop
is necessary for WriteNode( ).
Derek Harmon