SQLite to XML via PHP

engedi05

New Member
I am sure this can be done. I need to pull data from a SQLite db & convert it to XML on the fly, so it can be read by fusioncharts to display pretty graphs.I have seen it done with mysql but am finding it difficult to find information about SQlite to XML.\[code\]<?php header("Content-type: text/xml"); $host = "localhost"; $user = "root"; $pass = ""; $database = "test"; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT * FROM blog ORDER BY date DESC"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<entries>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<entry>\n"; $xml_output .= "\t\t<date>" . $row['date'] . "</date>\n"; // Escaping illegal characters $row['text'] = str_replace("&", "&", $row['text']); $row['text'] = str_replace("<", "<", $row['text']); $row['text'] = str_replace(">", ">", $row['text']); $row['text'] = str_replace("\"", """, $row['text']); $xml_output .= "\t\t<text>" . $row['text'] . "</text>\n"; $xml_output .= "\t</entry>\n"; } $xml_output .= "</entries>"; echo $xml_output; \[/code\]Taken from http://www.kirupa.com/web/mysql_xml_php.htmThanks in advance.
 
Back
Top