I have a PHP page that outputs XML by changing the header type and outputting the xml with an XSL stylesheet for an RSS feed:
<?php
header('Content-Type: text/xml; charset=utf-8');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
";
echo '<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="/path/feed.xsl"?>' . "
";
?>
<channel>
<item>...</item>...
</channel>
I want to pass some PHP variables from the original page to the XSL, how do I do this?
Example: I have the variables...
$header = "This is a cool page";
$description = "This is a description";
...that I want to pass to the XSL page and use within it meaning the title can be changed through PHP and dynamically changed in the XSL rather than hard coding it.
It cannot be passed through XML because I am using the XSL as a fallback and therefore the title should not be displayed when the browser supports RSS. Also it must come from that page rather than referencing another file with that variable.
Something like
<?xml-stylesheet title="XSL_formatting" type="text/xsl" param-header="<?=$header?>' param-description="<?=$description?>' href="/path/feed.xsl"?>
Let me know if there is a better way to achieve this.