Hi all
I have 3 files
a xsl stylesheet file, a php transformation file and a php file that dynamicaly produces xml from a mysql database.
what i want to do is transform the xml in the php file with the xsl stylesheet through the php processor file.
However i have encounted a number of problems due to the fact that my xml is generated in a php file.
the error i recieve is this
XSLT processing error: XML parser error 4: not well-formed (invalid token)
and my processor file is this:
Code:
Code:
<?
// Xml and XSL files
$xml_file = "test.php";
$xsl_file = "xml2.xsl";
// Allocate a new XSLT processor
$xh = xslt_create();
$fileBase = 'file://' . getcwd () . '/';
xslt_set_base ( $xh, $fileBase );
// Process the document
$result = xslt_process($xh, $xml_file, $xsl_file);
if (!$result) {
// Something croaked. Show the error
echo 'XSLT processing error: ' .xslt_error($xh);
}
else {
// Output the resulting HTML
echo $result;
}
// Destroy the XSLT processor
xslt_free($xh);
?>
it works fine if i use a standard xml file -- $xml_file = "test.xml";
however i require the xml to be dynamically generated due to an id variable and php is the way of doing this.
Does anyone have any idea how I can do an xsl transformation on a php file that generates xml??
thanks in advance
alex