Help in writing an a file format, vtu

Hi all,

I am trying to write a file of the following type.


<VTKFile type="UnstructuredGrid" version="0.1" byte_order="BigEndian">
  <UnstructuredGrid>
    <Piece NumberOfPoints="8" NumberOfCells="6">
      <PointData Scalars="scalars">
        <DataArray type="Float32" Name="pressure" Format="ascii">
          0.0
          1.0
          2.0
          1.0
          2.0
          3.0
          2.0
          3.0
        </DataArray>
        <DataArray type="Float32" Name="velocity" NumberOfComponents="3" Format="ascii">
          1.0 1.0 0.0
          2.0 1.0 0.0
          3.0 1.0 0.0
          1.0 2.0 0.0
          2.0 2.0 0.0
          3.0 2.0 0.0
          1.0 3.0 0.0
          2.0 3.0 0.0
        </DataArray>
      </PointData>
      <CellData Scalars="scalars">
        <DataArray type="Int32" Name="node_max" Format="ascii">
          3
          4
          4
          5
          6
          7
        </DataArray>
      </CellData>
      <Points>
        <DataArray type="Float32" NumberOfComponents="3" Format="ascii">
          0.0  0.0  0.0
          1.0  0.0  0.0
          2.0  0.0  0.0
          0.0  1.0  0.0
          1.0  1.0  0.0
          2.0  1.0  0.0
          0.0  2.0  0.0
          1.0  2.0  0.0
        </DataArray>
      </Points>
      <Cells>
        <DataArray type="Int32" Name="connectivity" Format="ascii">
           0  1  3
           1  4  3
           1  2  4
           2  5  4
           3  4  6
           4  7  6
        </DataArray>
        <DataArray type="Int32" Name="offsets" Format="ascii">
          3  6  9  12  15  18
        </DataArray>
        <DataArray type="Int32" Name="types" Format="ascii">
          5  5  5  5  5  5
        </DataArray>
      </Cells>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

I think this comes under an xml file format. So I looked up and got quick-xml and a few other crates which would provide me to do so. I have tried to understand it but I could get it. Mainly the event stuff and all the bytes stuff. Can some one please point me to a simpler resource to do so?

Thank you.

minidom_writer or xmlwriter have slightly simpler APIs than quick-xml, and might work well for this.