The following is text copied from the mysql(3) manual page:
You can execute SQL statements in a script file (batch file) like this:
shell> mysql db_name < script.sql > output.tab
The MySQL version 5.x and greater also provide a mysqldump which has an XML output switch. This causes mysqldump to output XML on stdout such that the mysqldump output can be used directly in an XML document output stream.