...I find that opening the DCR and saving it gets rid of all the empty elements and could be a much simpler way of doing it than parsing empty elements and deleting them...
...but what it does is, even though I have put many elements as nillable (not required), it still put them as empty elements after user saves the InfoPath form