我movieID
在以下 XSLT 代码中传递参数
<xsl:template match="movie">
<xsl:element name="a">
<xsl:attribute name="href">movie_details.php?movieID=<xsl:value-of select="@movieID"/></xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
<xsl:element name="br" />
</xsl:template>
我想通过并将其显示在名为movie_details.php
.
这是我的 movie_details.php 代码:
<?php
$xml = new DOMDocument();
$xml->load('movies.xml');
$xsl = new DOMDocument;
$xsl->load('movie_details.xsl');
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);
$params = $_GET['movieID'];
echo $proc->transformToXML($xml,$params);
?>
movie_details.xsl 页面顶部包含以下参数:
<xsl:param name="movieID"/>
我得到一个空白页,根本没有显示任何信息。
我可以通过使用以下 ColdFusion 代码 (movie_details.cfm) 让它工作
<cfset MyXmlFile = Expandpath("movies.xml")>
<cffile action="READ" variable="xmlInput" file="#MyXmlFile#">
<cfset MyXslFile = Expandpath("movie_details.xsl")>
<cffile action="READ" variable="xslInput" file="#MyXslFile#">
<cfset xslParam = StructNew() >
<cfset xslParam["movieID"] = "#url.movieID#" >
<cfset xmlOutput = XMLTransform(xmlInput, xslInput, xslParam )>
<!--- data is output --->
<cfcontent type="text/html" reset="yes">
<cfoutput>#xmloutput#</cfoutput>
但是,我想对 PHP 做同样的事情。