Implemented serializing to DOM elements.