Apr 1, 2010

My Iteration 3 Code XML


Ok heres my code, the issues I've had is that im only pulling back the titles. I want to pull back all the information from the blog site. So what the next step will be is to use Prof Drakes code to find a way to bring back not only titles, but content.

I got stuck on a few places, and I hope by posting this if any of you get stuck you can reference this. But first I got stuck by not adding

title= xmlDoc.documentElement.getElementByTagName("title"); on line 37. Also I got stuck by not adding

Current += title[i].firstChild.nodeValue;

So when your doing your project I hope that seeing this helps.
If anyone has an idea how to make this better please feel free to let me know. I can always use the help. I also used www.w3schools.com/js/js_obj_array.asp to get extra information on javascript arrays.


function getDetails() {
request = createRequest();
if (request == null) {
alert("Unable to create request");
return;
}
var url= "proxy.php";
request.open("GET", url, true);
request.onreadystatechange = displayDetails;
request.send(null);
}


function createRequest() {
try {
request = new XMLHttpRequest();
} catch (tryMS) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (otherMS) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
return request;
}

function displayDetails() {
if (request.readyState == 4) {
if (request.status == 200) {
xmlDoc=request.responseXML;
title = xmlDoc.documentElement.getElementsByTagName("title");
var Current
for (i=1; i {
Current += title[i].firstChild.nodeValue;
}
document.getElementById("Proxy").innerHTML=Current;
}
}
}

2 comments:

  1. I tried to add more information but it still doesnt look good. And now that ive added "description" thats all that appears, why cant they both show?

    ReplyDelete
  2. How are you incrementing the number on your loop? I am not sure what the += codding means. If this is your way of incrementing then you are upping the number before you even load up anything. In most the programming I have done in the other languages you wanted to up the number after you stuffed the information in your variable or array.

    ReplyDelete