Well,
According to the compiler, your first snippet won't compile, because
no overload for dd.Load takes a stringWriter as an argument.
C:\Inetpub\wwwroot\VBWebLab\XmlLoading.aspx.vb(35): Overload
resolution failed because no accessible 'Load' can be called with
these arguments:
'Public Overridable Sub Load(reader As System.Xml.XmlReader)':
Value of type 'System.IO.StringWriter' cannot be converted to
'System.Xml.XmlReader'.
'Public Overridable Sub Load(txtReader As System.IO.TextReader)':
Value of type 'System.IO.StringWriter' cannot be converted to
'System.IO.TextReader'.
'Public Overridable Sub Load(inStream As System.IO.Stream)': Value
of type 'System.IO.StringWriter' cannot be converted to
'System.IO.Stream'.
'Public Overridable Sub Load(filename As String)': Value of type
'System.IO.StringWriter' cannot be converted to 'String'.
so are you sure your first snippet works? Perhaps you did not supply
a piece of code.
Secondly, you are getting an error because you are loading nothing
into to the document, there is no root element contained in either of
your snippets, both streams are empty.
What exactly are you trying to accomplish? A little more context might
let the list give you some better guidance.
On Apr 11, 2005 6:59 PM, Nick Chan <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I have the following situation and hope someone can assist me. When I load an
> xml document written to a XmlTextWriter object, I can read the data from the
> embedded StringWriter and load it into an Xml Document object.
>
> However, if I use a memory stream object instead of a StringWriter object, I
> get an "Root Element Missing" error message from dot net.
>
> The following snippet works ............
>
> Dim sw As System.IO.StringWriter
> sw = New System.IO.StringWriter
> writer = New System.Xml.XmlTextWriter(sw)
> Dim dd As New XmlDocument
> dd.load(sw)
>
> The following snippet doesnt work ...........
>
> Dim mem As System.IO.MemoryStream
> Dim node As System.Xml.XmlNode
> mem = New System.IO.MemoryStream(node.InnerText.Length)
> writer = New System.Xml.XmlTextWriter(mem)
> Dim dd As New XmlDocument
> dd.load(mem) ''''' Craps out right here
>
> Can anyone pleeeeeeeeeeease help, thanks.
>
> NIck
>
> ps: The reason I need to use the MemoryStream instead is because the
> stringwriter encodes the text with UTF-16 and IE only recognizes UTF-8.
>
>
> ---------------------------------
> Post your free ad now! Yahoo! Canada Personals
>
> [Non-text portions of this message have been removed]
>
> Yahoo! Groups Links
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/