Load webbrowser control from stream

By Allen Stoner

Many times when using XML and XSLT to transform it into an HTML document it is nice to put the output directly into the web browser control without writing it to a temporary file. This can be done by putting the transformation output into a memory stream and loading the web browser control from the memory stream.

    Dim xData As New  Xml.XmlDocument
    Dim xXSLT As New Xml.Xsl.XslCompiledTransform
    Dim TransformStream As New System.IO.MemoryStream
    Dim TransformWriter As New System.Xml.XmlTextWriter(TransformStream, System.Text.Encoding.ASCII)

    xData.Load('xml data file here')
    xXSLT.Load('xslt stylesheet file here')

    xXSLT.Transform(xData, TransformWriter)
    TransformStream.Position = 0

    WebBrowser1.DocumentStream = TransformStream

Load webbrowser control from stream  (2140 Views)