var s = new XMLSerializer().serializeToString(document.getElementById("svg")) var encodedData = window.btoa(s);