ASP.NET XSLT 转换问题

发布于 2024-11-15 11:23:07 字数 1169 浏览 0 评论 0原文

我需要帮助解决以下问题。我解析 XML 并进行 XSLT 转换。 Stylus Studio 一切都很好。但对于 ASP.NET 我无法解析和输出。

min.aspx.vb

Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Imports System.IO


Partial Class Poseidon_min
    Inherits System.Web.UI.Page


    Protected Sub Literal1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Literal1.PreRender

        Dim strXSLTFile As String = "http://www.kiris-alinda.de/Poseidon/Hotelangebote.xslt"
        Dim strXMLFile As String = "http://www.kiris-alinda.de/Poseidon/PosXMLReq/PosXMLReqSearch.php?htc=AYTLIND"



        Dim reader As XmlReader = XmlReader.Create(strXMLFile)

        Dim objXSLTransform As New XslCompiledTransform()

        objXSLTransform.Load(strXSLTFile)

        Dim htmlOutput As New StringBuilder()

        'Dim htmlWriter As TextWriter = New StringWriter(htmlOutput)

        'objXSLTransform.Transform(reader, Nothing, htmlWriter)


        Me.Literal1.Text = htmlOutput.ToString()

        reader.Close()

    End Sub
End Class

为什么无法从 ASP.NET 中的 XSLT 输出

I need help with the following issue. I parse XML and do a XSLT transformation. Everything is fine with Stylus Studio. But with ASP.NET I can't parse and output.

min.aspx.vb

Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Imports System.IO


Partial Class Poseidon_min
    Inherits System.Web.UI.Page


    Protected Sub Literal1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Literal1.PreRender

        Dim strXSLTFile As String = "http://www.kiris-alinda.de/Poseidon/Hotelangebote.xslt"
        Dim strXMLFile As String = "http://www.kiris-alinda.de/Poseidon/PosXMLReq/PosXMLReqSearch.php?htc=AYTLIND"



        Dim reader As XmlReader = XmlReader.Create(strXMLFile)

        Dim objXSLTransform As New XslCompiledTransform()

        objXSLTransform.Load(strXSLTFile)

        Dim htmlOutput As New StringBuilder()

        'Dim htmlWriter As TextWriter = New StringWriter(htmlOutput)

        'objXSLTransform.Transform(reader, Nothing, htmlWriter)


        Me.Literal1.Text = htmlOutput.ToString()

        reader.Close()

    End Sub
End Class

Why is it not possible to output <xsl:value-of select="PosXmlResponse/search/date/@min"/> from the XSLT in ASP.NET?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

碍人泪离人颜 2024-11-22 11:23:07

看看这个:

XML / XSLT 转换 < /a>

您必须在 ASPX 页面上使用 XML 服务器控件,然后设置 XSLT 转换

Take a look at this :

XML / XSLT Transformation

You have to use an XML Server Control on the ASPX page and then setting up XSLT Transformation

鹿童谣 2024-11-22 11:23:07

我使用这段代码:

Public Shared Function Transform(xml As String, xsl As String, argsList As XsltArgumentList) As String
    Dim selectedXml As XDocument = XDocument.Parse(xml)
    Dim xmlTransform As New XslCompiledTransform()

    Dim htmlOutput As New StringBuilder()
    Dim writer As XmlWriter = XmlWriter.Create(htmlOutput)

    xmlTransform.Load(New XmlTextReader(New StringReader(xsl)))
    xmlTransform.Transform(selectedXml.CreateReader(), argsList, writer)

    Return htmlOutput.ToString()
End Function

I use this code:

Public Shared Function Transform(xml As String, xsl As String, argsList As XsltArgumentList) As String
    Dim selectedXml As XDocument = XDocument.Parse(xml)
    Dim xmlTransform As New XslCompiledTransform()

    Dim htmlOutput As New StringBuilder()
    Dim writer As XmlWriter = XmlWriter.Create(htmlOutput)

    xmlTransform.Load(New XmlTextReader(New StringReader(xsl)))
    xmlTransform.Transform(selectedXml.CreateReader(), argsList, writer)

    Return htmlOutput.ToString()
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文