Link to home
Start Free TrialLog in
Avatar of Kai77
Kai77

asked on

Show data of MemoryStream in a literal control

I am using the XMLtextwriter to create  XML data. The writer writes the data into a memorystream. Once it is finished I would like to show the XML data in a literal control, before I use an XSL file for a transformation.

My code:

        Dim oMemoryStream As New System.IO.MemoryStream
        Dim oXMLWriter As System.Xml.XmlTextWriter
        oXMLWriter = New System.Xml.XmlTextWriter(oMemoryStream, System.Text.Encoding.UTF8)

        With oXMLWriter
            .Formatting = System.Xml.Formatting.Indented
            .Indentation = 4
            .IndentChar = CChar(" ")
            .WriteStartDocument()
            .WriteStartElement("navigation")

            Call WriteNavigationItems(oXMLWriter, PageInfo.AtaChapterID)

            .WriteEndElement()
            .WriteEndDocument()
        End With

        oXMLWriter.Flush()

        oMemoryStream.Position = 0
        Dim XMLdoc As New XPathDocument(oMemoryStream)
        oMemoryStream.Close()

        Dim stylesheet As New XslTransform
        stylesheet.Load("E:\BA - Projects\Bright Alley\wwwroot\FE\ba_controls\default\navigation.xslt")

        Dim oStringWriter As New System.IO.StringWriter
        stylesheet.Transform(XMLdoc.CreateNavigator(), Nothing, oStringWriter, Nothing)
        ltlNavigation.Text = oStringWriter.ToString

        oXMLWriter.Close()
ASKER CERTIFIED SOLUTION
Avatar of b1xml2
b1xml2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it is important to use the proper naming conventions. Avoid the Hungarian notation as whatever that applied in VB is not necessarily correct in VB.NET

All instances of classes are objects. Thus, there is no need to use the prefix o.

HTH
Avatar of Kai77
Kai77

ASKER

Ok thanks man