Created
February 26, 2013 22:37
-
-
Save ninjascribble/5042981 to your computer and use it in GitHub Desktop.
Saving dynamically created SVG in a WinJS app via the Windows.Data.Xml.Dom API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Windows.Storage.ApplicationData.current.localFolder.createFileAsync("example.svg", Windows.Storage.CreationCollisionOption.replaceExisting) | |
| .then(function(storageFile) { | |
| var serializer = new XMLSerializer() | |
| , xmldoc = new Windows.Data.Xml.Dom.XmlDocument() | |
| , xmlLoadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings() | |
| , svgnode = document.querySelector('.container > svg') | |
| , svgstr = serializer.serializeToString(svgnode) | |
| xmlLoadSettings.prohibitDtd = false; | |
| xmlLoadSettings.resolveExternals = true; | |
| xmldoc.loadXml(svgstr, xmlLoadSettings); | |
| xmldoc.saveToFileAsync(storageFile); | |
| }) | |
| .done(function() { | |
| // hooray! | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment