Flat XML
FlatXmlDataSet reads and writes flat XML dataset documents. Each XML element corresponds to a table row. Each XML element name corresponds to a table name. The XML attributes correspond to table columns.
Flat XML dataset document sample:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd">
<dataset>
<TEST_TABLE COL0="row 0 col 0" COL1="row 0 col 1" COL2="row 0 col 2"/>
<TEST_TABLE COL1="row 1 col 1"/>
<SECOND_TABLE COL0="row 0 col 0" COL1="row 0 col 1" />
<EMPTY_TABLE/>
</dataset>To specify null values, omit the corresponding attribute. In the above example, the missing COL0 and COL2 attributes of TEST_TABLE’s second row represent null values.
Table metadata is deduced from the first row of each table. On a later row, an attribute the first row lacked is ignored — the row is still read, just without that column, with an "Extra columns on line x" warning — unless you enable column sensing or supply a DTD. See Dataset Values: column sensing for the fix. Beware you may get a NoSuchColumnException if the first row of a table has one or more null values. Because of that, using a DTD is recommended: DbUnit then takes each table’s metadata from the columns declared in the DTD. DbUnit supports only an external system URI for the DTD; it can be absolute or relative.
ReplacementDataSet’s [NULL placeholder] is another
way to cope with a first-row null.
For binary/BLOB data, literal and relative dates, UUID literals, booleans and numbers from strings, and empty-string handling, see Dataset Values — those rules are the same for every format.
Build one with FlatXmlDataSetBuilder:
IDataSet dataSet = new FlatXmlDataSetBuilder().build(new File("dataset.xml"));

