I'm not sure if I have the syntax right or if I'm using the wrong code or what, but I just can't seem to get this to work. Please someone point me in the right direction.
my xml set up is like this:
<gallery>
<picture>
<src>Source Here</src>
<alt>Alt text here</alt>
</picture>
</gallery>
Code:
function ajaxRequest(){
var URL = "pictures.xml";
var request = false;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
request.open("GET", URL, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseText;
var xDocument = xmlDoc.getElementsByTagName("picture");
var numXml = xDocument.length;
var setNumbers = numXml / 4;
for (i=0;i<numXml;i++){
srcArray[i] = xmlDoc.getElementsByTagName("src")[i].firstChild.nodeValue;
altArray[i] = xmlDoc.getElementsByTagName("alt")[i].firstChild.nodeValue;
img = "<img src=\'"+srcArray[i]+"\' onClick=\'replaceMain("+i+")\' onmouseover=\"this.style.cursor=\'pointer\'\" alt=\'"+altArray[i]+"\' width=144 height=108 >";
imageArray[i] = "<li>"+img+"</li>";
}
}
}
request.send(null);
}
<gallery>
<picture>
<src>Source Here</src>
<alt>Alt text here</alt>
</picture>
</gallery>
Comment