and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi there.i am having this xml file, [url]http://www.houseonmap.gr/areadata.xml[/url],
and getting the data (X and Y) in this manner
[syntax="javascript"]
for(i=0;i<N;i++){
tempTerritory = ter_list[i];
tempid = tempTerritory.getAttribute("id");
if(tempid==id_wanted){
X=tempTerritory.getElementsByTagName("t_X")[0].childNodes[0].nodeValue;
Y=tempTerritory.getElementsByTagName("t_Y")[0].childNodes[0].nodeValue;
break;
}
var area_list = tempTerritory.getElementsByTagName("area");
for(j=0;j<area_list.length;j++){
tempArea = area_list[i];
tempid = tempArea.getAttribute("id");
if(tempid==id_wanted){
X=tempArea.getElementsByTagName("X")[0].childNodes[0].nodeValue;
Y=tempArea.getElementsByTagName("Y")[0].childNodes[0].nodeValue;
break;
}
}
}
for some reason i am getting only when the wanted id is 1,2,3, 11,22,33 and never for 12,21,23,31,32
If anyone can help it would be great.thanks
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Sarris, we've had to edit at least eight of your forty posts to use syntax highlighting. That's a very high percentage. Please start using the syntax highlighting tags.
/*AJAX*/
function getHTTPObject() {
if (typeof XMLHttpRequest != 'undefined') {
return new XMLHttpRequest();
}
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {} } return false;
}
function makeRequest(id_wanted){
var url = "http://www.houseonmap.gr/areadata.xml";
var http_request = getHTTPObject();
http_request.open("GET", url, true);
http_request.onreadystatechange = function() {
if(http_request.readyState == 4) {
if(http_request.status == 200){
GetData(http_request,id_wanted);
}
}
}
http_request.send(null);
}
function GetData(http_request,id_wanted){
map.setZoom(6);
var response = http_request.responseXML;
//GET THE ROOT OF THE DATA
var root = response.documentElement;
var ter_list = root.getElementsByTagName("Territory");
var N = ter_list.length;
var FLAG; //0 is territory 1 is area...moreover when flag = 1 means area found so break out of the loop of the territories
var i;
var j;
var X;
var Y;
var tempTerritory;
var tempArea;
var tempid;
for(i=0;i<N;i++){
if(FLAG == 1) break;
FLAG = 0;
tempTerritory = ter_list[i];
tempid = tempTerritory.getAttribute("id");
if(tempid==id_wanted){
X=tempTerritory.getElementsByTagName("t_X")[0].childNodes[0].nodeValue;
Y=tempTerritory.getElementsByTagName("t_Y")[0].childNodes[0].nodeValue;
FLAG = 0;
break;
}
var area_list = tempTerritory.getElementsByTagName("area");
for(j=0;j<area_list.length;j++){
tempArea = area_list[i];
tempid = tempArea.getAttribute("id");
if(tempid==id_wanted){
X=tempArea.getElementsByTagName("X")[0].childNodes[0].nodeValue;
Y=tempArea.getElementsByTagName("Y")[0].childNodes[0].nodeValue;
FLAG = 1;
break;
}
}
}
document.form1.Acor.value = i;
document.form1.Bcor.value = j;
document.form1.Ccor.value = area_list.length;
document.form1.Dcor.value = FLAG;
document.form1.Ycor.value = Y;
document.form1.Xcor.value = X;
if(FLAG == 0) {map.setZoom(12);}
if(FLAG == 1) {map.setZoom(14);}
map.panTo(new GLatLng(Y, X));
http_request.abort();
}