I have a simple servlet application that sends XML response to JavaScript. When I check in my Firebug, This resposonse is received by JavaScript as
<valid> AT&T,0.51851370625875,0.97944711419669,Verizon,0.47641942539114,0.99005717081381,wifi,0.48596657869633,0.88912486160201 </valid>
Which is a perfectly valid XML response - but Firebug also shows XML error
XML Parsing Error: not well-formed Location: moz-nullprincipal:{30f70c51-7f01-48b4-9f69-4f0093e02ba6} Line Number 1, Column 12:
<valid>AT&T,0.51851370625875,0.97944711419669,Verizon,0.47641942539114,0.9900571...
It shows the error at the first comma - which does not makes sense at all. I even tried replacing commas with spaces - but even that gives same problem.
I generate my response from Servlet by
String ret="";
for (int i=0; i < ping.size(); i++)
{
ret += ping.get(i) ;
if(i != ping.size()-1){
ret += ",";
}
}
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write("<valid>"+ret+"</valid>");
And in my JavaScript, I try to retrieve data as
var message = xmlHttp.responseXML.getElementsByTagName("valid")[0].childNodes[0].nodeValue;
I have use this exact same approach before - not sure why is this not working anymore.
All I need to do is store the values (AT&T,0.51851370625875,0.97944711419669,Verizon,0.47641942539114,0.99005717081381,wifi,0.48596657869633,0.88912486160201)
in a javascript array.
Any ideas?