0

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

3 Answers 3

4

Just pull the data out and manually form it into an XML document (using the DOM or XMLWriter classes), there's no built in way to just do it. If you're looking for a pre-built solution though, PHPMyAdmin has functionality to dump a table to an XML document.

Sign up to request clarification or add additional context in comments.

Comments

0

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

0

You should consider the XQuery PHP extension to customize your XML output from Mysql: http://www.zorba-xquery.com/site2/html/php.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.