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

Forum statistics

Threads
474,002
Messages
2,570,258
Members
46,857
Latest member
ArleenWill

Latest Threads

Top