On Tue, 26 Oct 2004 13:13:54 -0400, Jekke Bladt <[EMAIL PROTECTED]> wrote:
> All--
>
> I have an XmlTextWriter that writes to a MemoryStream. Once the XML is
> written, I would like to retrieve it as a string. What is the best way
> to do this?
>
> Here is the code for writing:
>
> MemoryStream theStream = new MemoryStream();
> XmlTextWriter xtw = new XmlTextWriter(theStream, Encoding.UTF8);
> xtw.WriteStartElement(_Name);
> xtw.WriteAttributeString("type", this.GetType().ToString());
> xtw.WriteAttributeString("scope",
>         ConfigurationManager.ScopeName(this.Scope));
> xtw.WriteAttributeString("value", _Value);
> xtw.WriteEndElement(); // _Name
> xtw.Flush();

string theString = System.Text.Encoding.UTF8.GetString(theStream.ToByteArray())

--
Steve Johnson

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to