Interested how to do it programmatically, not export table data once (there are tools for sure).
easiest way to transform mysql table “as is” into xml document ?
table contains say 2 rows:
id name
1 “John Travolta”
2 “Mary Lynch”
ideally we’d need a class that’s gonna eat login/passw/host of a database and
GoodClass goodClass = new GoodClass(login, passw, host);
String xml = goodClass.getTableData(nameOfTable);
// xml : <table><row><num>1</num><id>1</id><name>John Travolta</name></row><row><num>2</num><id>2</id><name>Mary Lynch</name></row></table>
If you wanted to go overboard, you could use hibernate to get your database results as Java objects and then use JAXB or JiBX to marshal the objects to XML. But the easiest way is to connect to your database, execute a query, loop over the resultset and build the XML. Example code is shown below: