J
Julius Mong
Dear all, I'm trying to download an external SVG document from an SVG doc
and then replace the current SVG with the new SVG DOM by:
function replaceSVG() {
var root = document.getDocumentElement();
while(root.hasChildNodes()) root.removeChild(root.firstChild);
root.appendChild(parseXML(content, document));
}
This works fine as long as the external SVG document contains no <?xml
version="1.0"?> and the resulting SVG would become somehting like <svg the
original><svg the loaded DOM svg elem>...</svg></svg>
I tried directly using:
document.replaceChild(parseXML(content,document),
document.getDocumentElement());
,and,
document.documentElement = parseXML(content,document);
to try to not have the outer <svg> wrapping the loaded svg tree. Neither
works, javascript errors resulted.
I must be missing something here, as I'm sure it can be done, so does anyone
know how I can achieve what I'm trying to? If possible could we deal with
external SVG documents that contain <?xml version="1.0"?> as the 1st line
too?
Thanks, Jules
and then replace the current SVG with the new SVG DOM by:
function replaceSVG() {
var root = document.getDocumentElement();
while(root.hasChildNodes()) root.removeChild(root.firstChild);
root.appendChild(parseXML(content, document));
}
This works fine as long as the external SVG document contains no <?xml
version="1.0"?> and the resulting SVG would become somehting like <svg the
original><svg the loaded DOM svg elem>...</svg></svg>
I tried directly using:
document.replaceChild(parseXML(content,document),
document.getDocumentElement());
,and,
document.documentElement = parseXML(content,document);
to try to not have the outer <svg> wrapping the loaded svg tree. Neither
works, javascript errors resulted.
I must be missing something here, as I'm sure it can be done, so does anyone
know how I can achieve what I'm trying to? If possible could we deal with
external SVG documents that contain <?xml version="1.0"?> as the 1st line
too?
Thanks, Jules