> From reading various posts on similar subjects, I have come up with
> the following test code (using 2 constants, rather than my dataset
[quoted text clipped - 3 lines]
> Dim doc As New XmlDocument
> Dim xmlStream As Stream = New MemoryStream
Dim xmlStream As MemoryStream = New MemoryStream
> Dim xmlWriter As New XmlTextWriter(xmlStream, Encoding.UTF8)
> ' Dim xmlWriter As New XmlTextWriter(Console.Out)
[quoted text clipped - 9 lines]
> xmlWriter.WriteEndDocument()
> Try
Insert here
xmlStream.Position=0
> doc.Load(xmlStream)
> Catch ex As Exception
> MsgBox(ex, ex.Message)
> End Try
btw, you can write directly to XmlDocument using Chris Lovett's XmlNodeWriter
class (find it in gotdotnet.com).

Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Steve Gilbey - 09 Oct 2003 09:40 GMT
Thanks Oleg,
Your suggestion, plus one from elsewhere got me going.
It seems it wasn't enough to just position the stream, the stream and
the writer also need to be flushed before I got anything into Doc.
Adding this:
xmlWriter.Flush()
xmlStream.Flush()
xmlStream.Position = 0
before the doc.load fixed it. Also note, it needs Position AFTER the
flush. The other way around doesn't work.
However in the meantime, I followed your suggestion and got the
XmlNodeWriter and am now using that instead!
Rgds
Steve
> > From reading various posts on similar subjects, I have come up with
> > the following test code (using 2 constants, rather than my dataset
[quoted text clipped - 30 lines]
> btw, you can write directly to XmlDocument using Chris Lovett's XmlNodeWriter
> class (find it in gotdotnet.com).