serializeToString

The XMLSerializer method serializeToString() constructs a string representing the specified DOM tree in XML form.

MDN Reference