This is a very neat function. I may be able to use it. Having said that I
think it is best left as a userland function.
Brian Moon
------------------------------------------
dealnews.com, Inc.
Makers of dealnews & dealmac
http://dealnews.com/ | http://dealmac.com/
----- Original Message -----
From: "Eliot Shepard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 3:38 PM
Subject: [PHP-DEV] mysql_fetch_xml
> I have written a simple PHP function which returns all result rows
> associated with a mysql query as an XML document. I needed this to
> facilitate XSLT presentation of database records.
>
> I was thinking about reimplementing the function in C and contributing
> it to php_mysql.c. Would there be any interest in incorporating this
> into the codebase?
>
> Eliot
>
>
> The PHP function:
>
> <?php
>
> function mysql_fetch_xml($result) {
> // turn an mysql query result into an xml document.
>
> $retval = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
> $retval .= "<result>";
>
> while ($row = mysql_fetch_assoc($result)) {
> $retval .= "<row>";
> while(list($key, $value) = each($row)) {
> $retval .= "<$key>$value</$key>";
> }
> $retval .= "</row>";
> }
>
> $retval .= "</result>";
>
> return $retval;
> }
>
> ?>
>
> Here's a usage example:
>
> $rows = mysql_query($query, $dblink);
> $xml = mysql_fetch_xml($rows);
>
> $parser = xslt_create();
> $xsl = join ('', file ('./present_rows.xsl'));
> xslt_process($xsl, $xml, $result);
> xslt_free($parser);
>
> print $result;
>
>
> --
> Eliot Shepard
> [EMAIL PROTECTED]
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]