I have a web document that contains a div element.
That div element contains an svg child element (which itself contains SVG primitives: text, path, etc.).
Ultimately, I would like to export that svg element into a proper, self-contained SVG document. (I can then run that SVG document through imagemagick and make publication-quality figures.)
Is there JavaScript that will "dump" the contents of the div element with the requisite <?xml> header into a file?