Skip to content

Instantly share code, notes, and snippets.

@tmn
Last active August 29, 2015 13:57
Show Gist options
  • Save tmn/9397926 to your computer and use it in GitHub Desktop.
Save tmn/9397926 to your computer and use it in GitHub Desktop.
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "test.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
var root = xmlDoc.firstChild;
var children = root.children;
// Eksempel:
// children[0]; er lst-noden
// children[1]; er result-noden
var results = children[1].childNodes;
for (var i = 0; i < results.length; i++) {
var res = results[i];
for (var j = 0; j < res.getElementsByTagName("str").length; j++) {
if (res.getElementsByTagName("str")[j].getAttribute("name") == "title") {
console.log("skriv ut tittel: " + res.getElementsByTagName("str")[j].innerHTML);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment