This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Mozilla XML > August 2005 > xmlhttp.responseXML parsing





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author xmlhttp.responseXML parsing
Jonathan Bond

2005-07-20, 9:10 pm

Hi guys,

I am using the following code snippet to parse an xmlhttp request:

if(xmlhttp.responseXML) {
var xmlresponce = xmlhttp.responseXML;

if(xmlresponce.documentElement.tagName == "parsererror"){
var parseErrorText =
xmlresponce.documentElement.firstChild.data;
parseErrorText += "\n" +
xmlresponce.documentElement.firstChild.nextSibling.firstChild.data;
alert(parseErrorText);
return;
}

var update_count =
xmlresponce.getElementsByTagName("updates")[0].firstChild.nodeValue;
var error_count =
xmlresponce.getElementsByTagName("errors")[0].firstChild.nodeValue;
}

Now if I send the following XML (from the server)
<?xml version = "1.0"?>
<responce>
<errors>0</errors>
<updates>2</updates>
</responce>

I get a parsing error in firefox (it complains about <?xml version = "1.0"?>
!!??)

So sending the following simple XML works:
<responce>
<errors>0</errors>
<updates>2</updates>
</responce>

Could anyone clarify how firefox parses the responseXML ? I don't see why it
should fail parsing the XML tag.. This works well in IE, shouldn't it be
best to allow specifying the XML version and encoding.. ?

I'm using firefox v1.0.6 on windows xp

best,
jon





blblack

2005-08-17, 11:24 pm

Jon,

Have you double-checked your Content-type headers? The XML should
probably be sent with the 'text/xml' content-type, or something
similar.

-- Brandon

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews