I have a MySQL database on my server and I'd like a certain table to be returned via PHP as XML. I've seen various ways to get XML to MySQL, but not an easy to follow way of the opposite. How should I go about doing so?
2
-
Lots of solutions on the net - you need to format the xml yourselfAdrian Cornish– Adrian Cornish2012-01-10 02:54:49 +00:00Commented Jan 10, 2012 at 2:54
-
possible duplicate with: stackoverflow.com/questions/2927193/… or stackoverflow.com/questions/1433267/…insumity– insumity2012-01-10 02:55:32 +00:00Commented Jan 10, 2012 at 2:55
Add a comment
|
3 Answers
Seconding using XMLWriter or DOM to generate XML in PHP. An alternate approach would be to use the mysql command, which will write out simple XML structures. Something like this:
header("Content-type: application/xml");
passthru('mysql mydatabase --xml -umysqluser -pmysqlpassword -e "SELECT * FROM mytable");
Comments
You should consider the XQuery PHP extension to customize your XML output from Mysql: http://www.zorba-xquery.com/site2/html/php.html