All versions: 3.11 | 3.10 | 3.9 | 3.8 | 3.7 | Development versions: 3.12 | Unsupported versions: 3.6 | 3.5 | 3.4 | 3.3 | 3.2 | 2.6

// Fetch books and format them as XML
String xml = create.selectFrom(BOOK).fetch().formatXML();

The above query will result in an XML document looking like the following one:

<result xmlns="http://www.jooq.org/xsd/jooq-export-3.10.0.xsd">
  <fields>
    <field schema="TEST" table="BOOK" name="ID" type="INTEGER"/>
    <field schema="TEST" table="BOOK" name="AUTHOR_ID" type="INTEGER"/>
    <field schema="TEST" table="BOOK" name="TITLE" type="VARCHAR"/>
  </fields>
  <records>
    <record>
      <value field="ID">1</value>
      <value field="AUTHOR_ID">1</value>
      <value field="TITLE">1984</value>
    </record>
    <record>
      <value field="ID">2</value>
      <value field="AUTHOR_ID">1</value>
      <value field="TITLE">Animal Farm</value>
    </record>
  </records>
</result>

The same result as an org.w3c.dom.Document can be obtained using the Result.intoXML() method:

// Fetch books and format them as XML
Document xml = create.selectFrom(BOOK).fetch().intoXML();

See the XSD schema definition here, for a formal definition of the XML export format:
http://www.jooq.org/xsd/jooq-export-3.10.0.xsd

The jOOQ Logo