all groups > dotnet xml > may 2004 >
You're in the

dotnet xml

group:

XML DOM to Stream


XML DOM to Stream Sean Wegele via .NET 247
5/13/2004 5:45:48 PM
dotnet xml:
(Type your message here)

--------------------------------
From: Sean Wegele

I would like to get from
Xml.XMLDomDoc to a IO.MemoryStream

Any help? this is driving me nuts!

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

Re: XML DOM to Stream Martin Honnen
5/14/2004 2:35:14 PM


[quoted text, click to view]


[quoted text, click to view]

Here is a VB.NET example that loads an XML document into an DOM
XmlDocument, then saves it to a memory stream and then reloads from the
memory stream to show that it works:

Imports System
Imports System.IO
Imports System.Xml


Public Class Test20040514
Public Shared Sub Main (CmdArgs() As String)
Dim XmlDocument1 As XmlDocument
XmlDocument1 = New XmlDocument()
XmlDocument1.Load("test20040514.xml")
Console.WriteLine(XmlDocument1.OuterXml)
Dim MemStream As MemoryStream
MemStream = New MemoryStream()
XmlDocument1.Save(MemStream)
Dim XmlDocument2 As New XmlDocument()
MemStream.Position = 0
XmlDocument2.Load(MemStream)
Console.WriteLine(XmlDocument2.OuterXml)
End Sub
End Class

So all you need is the Save method and then pass in a MemoryStream to
that method
--

Martin Honnen
http://JavaScript.FAQTs.com/
AddThis Social Bookmark Button