Convert MySQL to XML via PHP

前端 未结 3 1835
广开言路
广开言路 2021-01-28 05:04

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 t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 05:35

    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"); 
    

提交回复
热议问题