Forum Moderators: open
I'm making a website where users can draw circles, polygons, etc. with SVG. Everything is handled with JavaScript. I'd like to add a feature that allows users to save their creation.
In PHP DOM there is a function saveXML() that returns XML document as string. Is there similar function for SVG/JavaScript? Or is there some other way to save dynamically created SVG file?
Thanks a lot for your answers!
My purpose is to get SVG document to text and then send the text to PHP file that saves the text into file. The problem is that I don't know how to get SVG into text.
I found this place: [keith-wood.name...] There's a function toSVG that "serialises the current diagram into an SVG text document". I just have no idea how to use it - yet.
edit:
Wow, I got it. This does the trick:
var root = document.documentElement;
alert(new XMLSerializer().serializeToString(root));