Results 1 to 2 of 2

Thread: responseXML not working

Hybrid View

  1. #1
    Join Date
    Apr 2012

    responseXML not working

    Hi guys,

    I've been stuck on this problem now for 2 days. It seems to be a common problem from searching on forums, but none of the suggestions has worked for me.

    I am requesting a document - fakeresponse.xml, but it is not returned in the responseXML - instead it is returned in responseText.

    Here is my xml (i have used an online validator - it is fine):

    <?xml version="1.0"?>
    <marker address="50 Kent Street" lat="-33.7670673" lng="150.9679327"/>
    <marker address="27 Acland Street" lat="-33.5621071" lng="149.8561493"/>
    <marker address="19 Riley Street" lat="-33.8534749" lng="142.1672888"/>


    and in javascript:


    var xmlhttp=false;
    var xmldoc;

    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (e) {
    if (!xmlhttp && window.createRequest) {
    try {
    xmlhttp = window.createRequest();
    } catch (e) {

    function getMarkers()
    xmlhttp.open("GET", "fakeresponse.xml", false);
    xmlHttp.setRequestHeader("Content-Type", "text/xml");

    xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState==4)
    xmldoc = xmlhttp.responseXML;
    //xmldoc = xmlhttp.responseText;

    alert(xmldoc); // This will not execute for responseXML, but will for responseText

    var xarray = xmldoc.documentElement.childNodes;



    Can anybody please spot what I am missing? Can jquery offer a better solution?

  2. #2
    Join Date
    Jul 2010
    Your problem was stated a couple of months ago, and I imagine you might have solved it.

    When you validated it, you basically just downloaded it to FF client from your server, right? If it were not valid, FF automatically reports parsing error.

    Can you check the HTTP response headers from your server, make sure they are sending "Content-Type: text/xml" and nothing other?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center