How to transform string of XML to HTML
-
My web method returns some XML as a string. I have a fairly simple XSLT file (trying to create HTML SELECT OPTION tags from the XML content). I think both are OK but I cannot figure out how to pass the string of XML to the Transform method and get my desired output streamed out to the web page.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim myProxyClass As New ServicesMDW.Service Dim countiesXML As String Dim xslt As New XslCompiledTransform() Dim xpathdoc As XPathDocument Dim xslFileName As String = Server.MapPath("UserControl_StateCounty.xsl") Try countiesXML = myProxyClass.GetCountiesForState("06", "P", "Guest") xpathdoc = New XPathDocument(countiesXML) xslt.Load(xslFileName) xslt.Transform(xpathdoc, Nothing, Response.OutputStream) Catch ex As Xsl.XsltException Trace.Write("Transform Failed") Catch ex As Exception Trace.Write(ex.Message) End Try End Sub
Here is the XSLT file "UserControl_StateCounty.xsl":Select County
Here is a snippet of the XML returned from web method:001 Alameda 06 005 AMADOR 06
John