Getting XML and HTML output.

By | January 31, 2013

Many people use MySQL in the console to execute a simple command, but did you know that MySQL can format the result of the query directly to XML or html?

The option -X will output the query result as XML
-H can be used to generate a HTML table containing the data.

$ mysql -X -e "select * from test" test
<?xml version="1.0"?>
<resultset statement="select * from test" xmlns:xsi="">
	<field name="test">152710</field>

Output as HTML

$ mysql -H -e "select * from test" test
<table border="1">

Leave a Reply