' Add a stylesheet ' expC1 Url Public Function AddStylesheet(ByVal tcUrl As String) As Boolean Dim lcText As String = "" Dim lcUrl As String = "" Dim llSuccess As Boolean = False Dim loMemoryStream As MemoryStream = New MemoryStream() Dim loXmlDocument As XmlDocument = New XmlDocument() Dim loXmlProcessingInstruction As XmlProcessingInstruction = Nothing Dim loXmlTextWriter As XmlTextWriter = Nothing ' Reset everything cMessage = "" ' Initialization lcUrl = tcUrl ' Trim everything lcUrl = Trim(lcUrl) Try ' Now load the in-memory stream XML data into the XML document loMemoryStream.Seek(0, SeekOrigin.Begin) loXmlDocument.Load(loMemoryStream) ' Now add the stylesheet processing instruction to the XML document lcText = "type=""text/xsl"" href=""" + lcUrl + """" loXmlProcessingInstruction = loXmlDocument.CreateProcessingInstruction("xml-stylesheet", lcText) loXmlDocument.InsertAfter(loXmlProcessingInstruction, loXmlDocument.FirstChild) ' Now write the document out to the final output stream loXmlTextWriter = New XmlTextWriter(oMemoryStream, System.Text.Encoding.ASCII) loXmlDocument.WriteTo(loXmlTextWriter) loXmlTextWriter.Flush() llSuccess = True Catch loError As Exception cMessage = loError.Message End Try Return llSuccess End FunctionoMemoryStream already exists as part of the class and is initialized when this method is called. This is pretty much as simplified as I could see unless there is something new since the last six years which would be better.