Convert SVGSVGElement to String
You can use XMLSerializer to convert elements to a string.
var s = new XMLSerializer();
var str = s.serializeToString(documentElement);
SVG is a DOM element, so you can simply use outerHTML
attribute of SVG Elements to get the serialized HTML.
var stringData = document.getElementById('my-svg').outerHTML;