Reading SVG (XML) file from web page

wxdqz

New Member
Hi all,

I am using JavaScript to read SVG file. At this moment I am reading
from a local SVG file and it is working. But now, I am going to want
to read SVG file from the webpage.

This is my code to read local SVG file (from local machine):

function init(){

readXML("SVGBarGraph.svg");
loadFile();
}
function readXML(url){
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.overrideMimeType ("text/xml");
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}

function processReqChange() {

if (req.readyState == 4 && req.responseXML) {
var resp = req.responseXML;
parseSVGFile(resp);
}
}

function parseSVGFile(svgDOM){
....... (my codes)
}

Could anyone help me or give me some advices?

Thanks in advance,

M.
 
Back
Top