title: XML output from MySQL query
body: <p><i>is there any chance of getting the output from a MySQL query directly to XML?</i></p>
  
  <p>Im referring to something like MSSQL has with <b>SQL-XML</b> plugin, for example:</p>
  
  <pre><code>SELECT * FROM table WHERE 1 FOR XML AUTO
  </code></pre>
  
  <p>returns text (or xml data type in MSSQL to be precise) which contains an XML markup structure generated
  according to the columns in the table.</p>
  
  <p>With <b>SQL-XML</b> there is also an option of explicitly defining the output XML structure like this:</p>
  
  <pre><code>SELECT
    1       AS tag,
    NULL    AS parent,
    emp_id  AS [employee!1!emp_id],
    cust_id    AS [customer!2!cust_id],
    region    AS [customer!2!region]
   FROM table
   FOR XML EXPLICIT
  </code></pre>
  
  <p>which generates an XML code as follows:</p>
  
  <pre><code>&lt;employee emp_id='129'&gt;
     &lt;customer cust_id='107' region='Eastern'/&gt;
  &lt;/employee&gt;
  </code></pre>
  
  <p><b><i>Do you have any clues how to achieve this in MySQL?</i></b></p>
  
  <p>Thanks in advance for your answers.</p>