Easiest - load your data in ParaView.
- File/Save Data… choose the vtu format with Data Mode “Ascii” - this should give you a good idea.
The output will include many additional things that you can skip (eg, the RangeMin, RangeMax).
Assuming you only have non-polyhedrals, generating the cells is fairly easy. In the Legacy format each entry in CELLS is prefixed by its size, Eg,
8 0 26 156 548 51 348 945 1624
4 20 312 1603 331
In the xml format this would be represented by two arrays. The connectivity is the list of vertices for the cells and the offsets are the cumulative end of the connectivity lists.
Eg,
<Cells>
<DataArray type="Int32" Name="connectivity" format="ascii">
0 26 156 548 51 348 945 1624 # <- Hex
20 312 1603 331 # <- Tet
...
</DataArray>
<DataArray type="Int32" Name="offsets" format="ascii">
8 12 ...
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii" >
...
</DataArray>
</Cells>