Groovy & MySQL

SQLtoXML

import groovy.sql.Sql
def query = 'select * from dx limit 2'
def jdbc_URL="jdbc:mysql://ec2-54-208-78-75.compute-1.amazonaws.com:3306/airs" 
def sql = Sql.newInstance(jdbc_URL, 
    'userairs', 'userairs', 'com.mysql.jdbc.Driver') 
 
println "<ROWSET>"
sql.rows(query).each{row->
  println "  <ROW>"
  row.each {println "    <$it.key><![CDATA[$it.value]]></$it.key>"}
  println "  </ROW>"
}
println "</ROWSET>"
<ROWSET>
  <ROW>
    <serv><![CDATA[1]]></serv>
    <tstamp><![CDATA[200910061341]]></tstamp>
    <code><![CDATA[0BL01U601XL70]]></code>
    <value><![CDATA[0]]></value>
    <vf><![CDATA[0]]></vf>
    <hand><![CDATA[0]]></hand>
    <a_ext><![CDATA[введена]]></a_ext>
  </ROW>
  <ROW>
    <serv><![CDATA[1]]></serv>
    <tstamp><![CDATA[200910061341]]></tstamp>
    <code><![CDATA[0BL01U602XL70]]></code>
    <value><![CDATA[0]]></value>
    <vf><![CDATA[0]]></vf>
    <hand><![CDATA[0]]></hand>
    <a_ext><![CDATA[введена]]></a_ext>
  </ROW>
</ROWSET>