Function to stringify a DOM to "canonic" form