<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: xml code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 05 Sep 2008 10:39:09 GMT</pubDate>
    <description>DZone Snippets: xml code</description>
    <item>
      <title>Get HTML/XML output of your MySQL queries.</title>
      <link>http://snippets.dzone.com/posts/show/3077</link>
      <description>The mysql command line utility can be used to build databases, manipulate them, etc.  It can also be used as an ad-hoc query tool with HTML-snippet output.  Consider this code:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql -e "SELECT * FROM mytable WHERE somecondition='somevalue'"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The resulting output will be a mess of +, - and | characters used to frame boxes around the values.  Now consider instead:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql -H -e "SELECT * FROM mytable WHERE somecondition='somevalue'"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The output of this is &lt;TABLE/&gt;&lt;TR/&gt;&lt;TD/&gt; code that can be cut-and-pasted into your HTML editor of choice.  Complex queries not easily put into a single -e string can be done thus:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql -H &lt; myqueries.sql&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note that no HTML is generated for any query that does not have a result set (like INSERT or UPDATE).&lt;br /&gt;&lt;br /&gt;Change the -H to a -X to get XML output (without a DTD/XSL description, unfortunately).</description>
      <pubDate>Mon, 04 Dec 2006 18:26:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3077</guid>
      <author>ttmrichter (Michael T. Richter)</author>
    </item>
  </channel>
</rss>
