Hi,
I have the following HTML code:
<.html"font-size: 150%; line-height: 116%;">as string using javascript?
Get the xml content of SVG file using Javascript
Re: Get the xml content of SVG file using Javascript
I assume it would be possible. But why can't you just open the XML Editor, and copy the content to a text file? Ooohh, I see! I surely don't understand why it's not possible to copy more than just one attribute, from the XML Editor.
Oh....well if you open an SVG file with a browser, so that you can see the XML code, you could probably copy it from there. I can't really explain how to do it, becuase I don't clearly understand it. But every now and then, when I click a link to see an SVG, I get a page full of XML instead of the image. I haven't figured out exactly how that happens. But it seems reasonable that should work. As for javascript, I'm clueless
Oh....well if you open an SVG file with a browser, so that you can see the XML code, you could probably copy it from there. I can't really explain how to do it, becuase I don't clearly understand it. But every now and then, when I click a link to see an SVG, I get a page full of XML instead of the image. I haven't figured out exactly how that happens. But it seems reasonable that should work. As for javascript, I'm clueless
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
-
- Posts: 55
- Joined: Wed May 30, 2012 11:17 pm
- Location: Belgium
Re: Get the xml content of SVG file using Javascript
Maybe if you send a XMLHttpRequest to retreive the file you could get its contents?
I use Inkscape 0.48 on Ubuntu 12.04.
English is not my natural language so excuse my mistakes.
Re: Get the xml content of SVG file using Javascript
Mathieu147 wrote:Maybe if you send a XMLHttpRequest to retreive the file you could get its contents?
Thanks, I'll try it
-
- Posts: 55
- Joined: Wed May 30, 2012 11:17 pm
- Location: Belgium
Re: Get the xml content of SVG file using Javascript
Maybe you are, but if you don't: use jQuery. That will be quite easy using the data() method.
I use Inkscape 0.48 on Ubuntu 12.04.
English is not my natural language so excuse my mistakes.
Re: Get the xml content of SVG file using Javascript
Thank you, Mathieu147, I managed to do it!
Re: Get the xml content of SVG file using Javascript
A simpler way than using an entire JQuery library is this one.. 10? lines of code..
http://127.0.0.1/httrack/svg_tutorials/ ... ntNode.svg
Don't forget to add this to the beginning of the script to make sure it works for all browsers.
if (typeof printNode=='undefined') {
printNode= function (el) {
return (new XMLSerializer()).serializeToString(el);
};
http://127.0.0.1/httrack/svg_tutorials/ ... ntNode.svg
Don't forget to add this to the beginning of the script to make sure it works for all browsers.
if (typeof printNode=='undefined') {
printNode= function (el) {
return (new XMLSerializer()).serializeToString(el);
};