responseText, responseXML parsing

V

vunet.us

My XML HTTP Request sends results in responseText. The result is an
XML file I will need to parse. After research I determined that a
cross browser XML parser will look like this:

responseXML.getElementsByTagName("to")[0].firstChild.nodeValue;

However, I receive responseText, not responseXML. Does anyone know of
the cross browser way to handle this problem?

Thank you.
 
M

Martin Honnen

My XML HTTP Request sends results in responseText. The result is an
XML file I will need to parse. After research I determined that a
cross browser XML parser will look like this:

responseXML.getElementsByTagName("to")[0].firstChild.nodeValue;

However, I receive responseText, not responseXML. Does anyone know of
the cross browser way to handle this problem?

Make sure the server sends its response with the HTTP response header
Content-Type: application/xml
or
Content-Type: text/xml
That way XMLHttpRequest/XMLHTTP knows it is receiving XML and then
populates responseXML.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top