user172987
user172987

Reputation:

How to convert a MySQL DB to XML?

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)

Upvotes: 13

Views: 36139

Answers (6)

Coornaert David
Coornaert David

Reputation: 1

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..

Upvotes: 0

user6411504
user6411504

Reputation:

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

Upvotes: 1

Alterlife
Alterlife

Reputation: 6625

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

Upvotes: 4

Rippo
Rippo

Reputation: 22424

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

Upvotes: 1

Svetlozar Angelov
Svetlozar Angelov

Reputation: 21680

mysqldump --xml test > test.xml

or

mysqldump -X test > test.xml

mysqldump to xml

Upvotes: 19

nickf
nickf

Reputation: 546433

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

Upvotes: 8

Related Questions