Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

Exporting XML

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

// 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">
    <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"/>
      <value field="ID">1</value>
      <value field="AUTHOR_ID">1</value>
      <value field="TITLE">1984</value>
      <value field="ID">2</value>
      <value field="AUTHOR_ID">1</value>
      <value field="TITLE">Animal Farm</value>

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:

References to this page


Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo