ctan wrote:
> The XML would be something like this...
>
> <?xml version="1.0" encoding="UTF-8"?>
<snip xml>
Just noticed something...
$line = mysql_fetch_array($result, MYSQL_ASSOC);
returns an array. Your $arguments array wants a string.
So..
$xml = join($line, '');
$arguments = array('/_xml'=> $xml);
Peter
>
> Hope this helps...
>
> chia
>
> -----Original Message-----
> From: Peter Clarke [mailto:[EMAIL PROTECTED]]
> Sent: 25 July 2002 13:06
> To: Ctan
> Cc: [EMAIL PROTECTED]
> Subject: Re: Applying XSL to XML with PHP
>
>
> Ctan wrote:
>
>>I'm trying to apply XSL to XML stored in a MySQL database with PHP.
>>How do I go about doing this? I've tried following the example on
>>php.net but I seem to run into a lot of trouble. Here's how the code
>>looks like (BTW aml is XML stored in the argument Table):
>>
>>
>>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);
>>
>>// 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 really need to solve this urgent. Thanks...
>>
>>Chia
>
>
> What is the xml. There may be a content encoding problem or some other
> xml issue.
>
> Peter
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php