Hello all. I'm returning some XML from PHP to Javascript via ajax and getting some 'invalid xml' errors. The xml I'm returning looks like this:
<response>
<song>tdb2009-01-29s2s06</song>
<song>tdb2009-01-29s1s02</song>
</response>
And my javascript to parse it looks like:
function u_handleServerResponse(){
//pull xml from xml response
var xmlResponse = xmlHttp.responseXML;
//check to see if xml was pulled
if(!xmlResponse || !xmlResponse.documentElement){
throw("Invalid XML Structure:\n" + xmlHttp.responseText);
}
//this is for catching errors with firefox
var rootNodeName = xmlResponse.documentElement.nodeName;
//check for errors
if(rootNodeName == "parsererror"){
throw("Invalid XML Strucutre");
}
//get the root
xmlRoot = xmlResponse.documentElement;
var songArray = xmlRoot.getElementsByTagName("song");
for(var i = 0; i < songArray.length; i++){
etc., etc...
And I'm getting a
Error reading the response: Invalid XML Strucutre
error. Does all this look right to you? Is the xml wrong or is it being loaded wrong? All help is greatly appreciated. Thanks in advance...