Using JavaScript to replace HTML content with content from an external XML file?



I'm trying to connect an XML file generated by an API with a (currently) static webpage, which can be found at http://ift.tt/1uXqoK3. I have an HTML file structured roughly like so:



<div>
<span id="content">No Content Yet</span>
</div>


and some Javascript in the <header> to determine what goes in the <span>:



<script>
function myFunction() {
document.getElementById("content").innerHTML = "Some Content Now!";
</script>


and <body onload="myFunction"> so it triggers on load.


This all works.


What I want to do is use an external XML file generated by an API (the Transport for London API, to be precise), hosted at a URI http://ift.tt/1feoVbJ, parse it for information using javascript, and use that information to update what my


document.getElementById("content").innerHTML = "Some Content Now!";


displays inside the quotes, i.e. replacing "Some Content Now!" with whatever the XML file generates that exists inside a certain tag, for example <Status Description="Good Service">, where "Some Content Now!" would be replaced by "Good Service".


I hope that broadly makes sense. I have no idea how to go about this so any help would be appreciated.


No comments:

Post a Comment