php “XSLTProcessor::setParameter” function

$xml= new DOMDocument();
$xml-> load(“testparam.xml”);

$xsl= new DOMDocument();
$xsl-> load(“testparam.xsl”);

$xsltproc= new XSLTProcessor();
$xsltproc-> importStylesheet($xsl);

$variable= “myvalue”;    //this part for passing parameter ‘myparam’ to xsl
$xsltproc->setParameter(”, ‘myparam’, $variable);

echo $xsltproc->transformToXML($xml);



<?xml version=”1.0″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=””&gt;
<xsl:template match=”/”>
–<p style=”color:red;”> Value parameter: <xsl:value-of select=”$myparam”/></p>
–<h2>Parameter works everywhere</h2>
–<table border=”1″>

—–<xsl:for-each select=”mytestnode”>

———–<td> <xsl:value-of select=”$myparam”/> </td>



2 thoughts on “php “XSLTProcessor::setParameter” function

  1. I think this is a powerfull site with a lot interesting articles about this stuff. And i just wanna thank you for this. I’ll follow your blog to see if you post more stuff like these!

Please Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s