note 35891 added to function.xslt-create

From: Date: Thu, 18 Sep 2003 09:23:46 +0000
Subject: note 35891 added to function.xslt-create
Groups: php.notes 
Request: Send a blank email to php-notes+get-56683@lists.php.net to get a copy of this message
In order to pass PHP variables into an XSL document you need to do the following: Firstly I created the following function to use: function GetXHTML($sXML, $sXSL, $aParameters) { $hXML = xslt_create(); $aArguments = array('/_xml' => $sXML, '/_xsl' => $sXSL); $sXHTML = xslt_process($hXML, 'arg:/_xml', 'arg:/_xsl', NULL, $aArguments, $aParameters); xslt_free($hXML); return $sXHTML; } Then call it like thus, passing the XML and XSL as a string with the final parameter being an array which can contain as many values as you wish to pass in: $sXHTML = GetXHTML($sXML, $sXSL, array("age"=>"26")); Then in the XSL document you need the following: <xsl:param name="age" /> Then where you want to display the value of age you do this: <xsl:value-of select="$age" /> Thanks now. ---- Manual Page -- http://www.php.net/manual/en/function.xslt-create.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35891 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35891&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35891&report=yes

« previous php.notes (#56683) next »