PHP Snippet 1:
<?php
$xmlUri = '/some/path/to/your.xml';
$xslUri = '/some/path/to/your.xsl';
$xmlDocument = new DOMDocument;
$xslDocument = new DOMDocument;
if ($xmlDocument->load($xmlUri) && $xslDocument->load($xslUri)) {
$xsltProc = new XSLTProcessor();
$xsltProc->setParam('php-file', htmlspecialchars($_SERVER['PHP_SELF']));
if ($xsltProc->importStyleSheet($xslDocument)) {
echo $xsltProc->transformToXML($xmlDocument);
}
}
PHP Snippet 2:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="php-file"/>
<xsl:template match="/">
<h2>My data</h2>
<form action="{$php-file}" method="post">
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Date</th>
</tr>
<xsl:for-each select="events/event">
<tr>
<td>Title: <input type="text" id="title" name="title" value="{title}"></input></td>
<td>Date: <input type="text" id="date" name="date" value="{date}"></input></td>
</tr>
</xsl:for-each>
<tr><td></td><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>
</xsl:template>
</xsl:stylesheet>