Given the following code:
$xml = file_get_contents($remote_url);
// The new stylesheet that will turn this XML into an HTML table
$stylesheet = '<?xml-stylesheet type="text/xsl" href="transform.xsl" ?>';
// Insert stylesheet reference into XML
$pos = '<?xml version="1.0" ?>'; //string we're searching for
$xsl = str_replace($pos, $pos.$stylesheet, $xml);
// Outputs the XML
header('Content-Type: text/xml');
echo $xsl;
Why am I still getting the plain XML without the transformation? If it matters, the php file output is being returned to a JavaScript XMLHttp request (so I can display the output in a div container).
Here's the transform.xsl code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Query Results</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Query Results</h1>
<table cellspacing="1">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Title</th>
<th scope="col">Link to FAQ</th>
<th scope="col">Product</th>
<th scope="col">Discovery Method</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="qdbapi/record">
<tr>
<td><xsl:value-of select="issue_id" /></td>
<td><xsl:value-of select="issue_title" /></td>
<td><xsl:value-of select="z_doclink" /></td>
<td><xsl:value-of select="product" /></td>
<td><xsl:value-of select="discovery_method" /></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thanks in advance for your help! I'm an experienced programmer, but am dipping my feet into Web and PHP coding for a project at work here.