Re: Passing xml between components

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Dennis Myrén (dennis_at_oslokb.no)
Date: 03/04/05


Date: Fri, 4 Mar 2005 09:40:40 +0100

I think what might be the problem.

If you write to the MemoryStream, and then want to read what you have
written from the beginning, then you will have to seek the MemoryStream back
to the beginning of stream.
So i think, one line of code might interest you(well, if it is not already
there..):
memoryStream.Seek(0x0, SeekOrigin.Begin);

-- 
Regards,
Dennis JD Myrén
Oslo Kodebureau
"PJChan" <PJChan@discussions.microsoft.com> wrote in message 
news:A56AA513-D0B1-43A4-A3D3-135D8CD1C756@microsoft.com...
> I'm trying to pass info between two components using xml. To produce the 
> xml
> I'm using an xmltextwriter, and in the receiving end I use an xmldocument 
> and
> its Load method to load the output of the writer.
>
> If I use an intermedary file I have no problem, but if I use a 
> MemoryStream
> (one of its purposes is to avoid the need for temporary files, right?) 
> then I
> get an error telling me that no root element was found.  How could this 
> be?!!
> Does anyone have an example of using a stream to pass xml around?
>
> While I'm in the subject, what would be the "correct" (or most 
> appropriate)
> way of passing the xml data between components? a string? a stream? an
> xmlreader? an xmldocument?
> -- 
> P.J. Chan 


Relevant Pages

  • Re: XmlTextReader errors with network stream after SP1
    ... The idea behind using a Stream was that we were going to pass pieces of XML ... Now I tried reading this into a StringReader and then into the Memorystream, ... Keith ...
    (microsoft.public.dotnet.xml)
  • Re: Passing xml between components
    ... Thanks for such a prompt reply Dennis; what you said made a lot of sense, ... XML column - Best Practices for Representing XML in the .NET Framework). ... then you will have to seek the MemoryStream back ... > to the beginning of stream. ...
    (microsoft.public.dotnet.framework)
  • No XmlNodeType for an EmptyElement with Attribute
    ... I have a MemoryStream of XML in which I wish to strip out the ... Dim myReader As New XmlTextReader ... 'Where p_Stream is the original MemoryStream of XML ...
    (microsoft.public.dotnet.xml)
  • Re: XmlDocument und StringArray (umwandeln eines StringArray in einen String und umgekehrt)??
    ... Ich muss dazu sagen das ich bis gestern mich nie sonderlich um XML gekümmert habe. ... Ich bekomme die Daten als Memorystream und muss Sie als Memorystream wieder setzten. ... (Wie gesagt mit xmlDocument bin ich noch nicht vertraut (24 Std)). ... XmlDocument.CreateTextNode nimmt nur ein string entgegen und liefert diesen. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Array to Xml to DataSet
    ... MemoryStream mem = new MemoryStream; ... > In order to read the contents of the stream into the DataSet you need to ... > MS MVP XML ... So I serialize the array to XML, ...
    (microsoft.public.dotnet.xml)