Welcome to WebmasterWorld Guest from 188.8.131.52
Forum Moderators: httpwebwitch
I have an issue that is driving me crazy. I have a xml document and associated stylesheet. I simply want to be able to 1: declare a top level variable 2. Pass a variable value from the URL to the stylesheet so that, for example, if [someurl.com...] - the information for the 3rd ID is displayed. Below i have sample code but i can't seem to get this to work with Php 5. Does anyone have a clue as to what is going on. After spending about a week looking through the documents for Php5 and XML, I am totally confused. Note: I am looking for the simplest / most direct solution.
// XML string
$xml = '<?xml version="1.0"?>
// XSL string
$xsl = '
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1" indent="no"
My PHP variable : <xsl:value-of select="$myvar"/><br />
My node set : <xsl:value-of select="$mynode"/>
$xh = xslt_create();
// the second parameter will be interpreted as a string
$parameters = array (
'myvar' => 'test',
'mynode' => '<foo>bar</foo>'
$arguments = array (
'/_xml' => $xml,
'/_xsl' => $xsl
echo xslt_process($xh, 'arg:/_xml', 'arg:/_xsl',NULL, $arguments, $parameters);
To get some data out of "node x", you can construct an XPATH describing that node, and use some of the simpler PHP methods for grabbing the value of that node.
This will get you started:
Example #1 on that page does what you're describing