Re: xslt_process
| From: | Peter Clarke | Date: | Mon, 22 Jul 2002 13:17:08 +0000 |
| Subject: | Re: xslt_process | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108854@lists.php.net to get a copy of this message | ||
Ctan wrote:
Hi all, I'm trying to use xslt_process() to transform a variable containing XML data
with an xsl file into a result using PHP. Incidentally the XML is from an external source, i.e. a database. However despite following the examples in
www.php.net I am unable to do so. The code works out to something like this:
if (! empty($searchword )) $query = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'"; $result = mysql_query($query) or die ("Query failed"); $line = mysql_fetch_array($result, MYSQL_ASSOC); var_dump($line); // Create an array $arguments = array('/_xml'=> $line); //XSL file $xsl = "./sheet1.xsl"; // Create an XSLT processor $xslthandler = xslt_create(); // Perform the transformation $html = xslt_process( $xslthandler, 'arg:/_xml', $xsl, NULL, $arguments); // Detect errors if (!$html) die ('XSLT processing error: '.xslt_error($xslthandler)); // Destroy the XSLT processor xslt_free($xslthandler); // Output the resulting HTML print $html; What I get on the screen is: Array ( [0] => "With the contents of my variable...") And: Warning: Sablotron error on line 1: XML parser error 2: syntax error in /home/httpd/html/ctan/resultworkingcopy2.php on line 93 XSLT processing error: XML parser error 2: syntax error What gives? I'm really frustrated and would greatly appreciate it if someone
would point out where I've made an error before I start ripping all my hair
out! Thanks... Thanks... Thanks! Regards, ChiaI may be missing something, but your not parsing XML. Your $line contains an array of data from the database, not xml.