How to convert a MySQL DB to XML?
Asked Answered
L

6

13

How can you convert a MySQL database to XML? I want everythimg... data and there relation in XML schema file

how to convert from sqlyog community 8.13(free version)

Lylalyle answered 14/9, 2009 at 7:53 Comment(3)
Do you mean data from the table?Debutante
How exactly do you want the data to be formatted?Tartrate
I want everythimg... data and there relation in XML schema fileLylalyle
R
19
mysqldump --xml test > test.xml

or

mysqldump -X test > test.xml

mysqldump to xml

Robustious answered 14/9, 2009 at 7:59 Comment(0)
M
8

phpMyAdmin has an Export to XML function in it. You could either use that, or examine the code to see how they did it.

Mascle answered 14/9, 2009 at 7:56 Comment(0)
T
4

The command line client that comes with MySQL has a --xml option: http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option_mysql_xml

If the output format of that does not match what you need, you could just select the data out and concatenate it with your xml tags:

select concat('<field1>',field1,'</field1><field2>',field2,
'</field2>') from table
Tartrate answered 14/9, 2009 at 8:0 Comment(0)
D
1

SQLyog also does a good implementation of exporting data to XML...

Debutante answered 14/9, 2009 at 7:59 Comment(1)
Right click on table and select "Backup/Export" and choose "Export table data as..." You can choose CSV, HTML, XML, Excel XML or SQL... Very handyDebutante
K
1

For a single table

mysql --xml -u username -p database_name table_name > table_name.xml

For a query

mysql --xml -u username -p database_name -e 'select * from table_name' > query.xml

For the whole database

mysqldump --xml -u username -p database_name > database.xml
Krak answered 10/7, 2016 at 16:43 Comment(0)
E
0

in fact it's actually

mysqldump --xml dbname -t tablename

with eventually -u username -pPASSWORD (or -p for an interactive passwd input) according to your privileges..

Eta answered 9/2, 2022 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.