tags:

views:

412

answers:

1

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?

A: 

You might want to look at the jQuery SVG plugin, in particular the toSVG() method in the SVG Defs section. You won't be able to save the document via Javascript/jQuery, but you should be able to open a new window with the document contents and use the browser's save functionality to save the text document to a file.

tvanfosson
Thank you, much appreciated!
Alex Reynolds