Formatting Output String from XMLSerializer().serializeToString

javascript, xml-serialization

Solution

I used vkBeutify with the following code.

var sXML = new XMLSerializer().serializeToString(document.getElementsByTagName("TopElementTag")[0]);
sXML = vkbeautify.xml(sXML);

Problem

I am using the following call to obtain the XML code for part of my DOM. ``` var sXML = new XMLSerializer().serializeToString(document.getElementsByTagName("TopElementTag")[0]); ``` However, when I display this string, it is all one line. Is there a way to format this string so that it has line breaks and tabs to make it easily humanly readable?

Original source