Following code accept the object and convert to XML, then content will be transformed to memory stream.
reportDetail is the object to pass to pass CreatXMLDoc
Dim currentStream As New MemoryStream() Dim streamWriter As New StreamWriter(currentStream) streamWriter.Write(CreateXMLDoc(reportDetail)) streamWriter.Flush() currentStream.Position = 0
reportDetail is the object to pass to pass CreatXMLDoc
Public Shared Function CreateXMLDoc(ByVal value As Object) As String Dim rv As String = "" Dim xml = New XmlSerializer(value.[GetType]()) Using memoryStream As MemoryStream = New MemoryStream() Using xmlWriter As XmlTextWriter = New XmlTextWriter(memoryStream, Encoding.UTF8) xmlWriter.Formatting = Formatting.Indented xml.Serialize(xmlWriter, value) rv = Encoding.UTF8.GetString(memoryStream.ToArray()) End Using End Using Return rv End Function