XML interfering with javascript variables



This is a simplified version of the project I am working on.



<!DOCTYPE html>
<html>
<body>

<script type="text/javascript">
var bridge;

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.open("GET","MarketSpreadsheet.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;


bridge = "xml data goes in here";

</script>


<svg height="300" width="300">
<text id="thePopUp" x="150" y="150" font-size="30" fill="black" visibility="visible"></text>
</svg>

<script type="text/javascript">
thePopUp.textContent = bridge;
</script>

</body>
</html>


I'm trying to create a dynamic svg element and for some reason, parsing the xml string directly into thePopUp.textContent wasn't working. My plan is to convert the xml data into a javascript variable matrix and use that to assign the text content. My issue is that the xml.http.send(); line is nullifying my variable assignment, making the output "undefined". I need that line to access my xml file, yet that line is keeping me from assigning the xml to a variable (or anything to a variable for that matter). Whats going on here?


No comments:

Post a Comment