treehouse : what would you like to learn today?
Web Design Web Development iOS Development

jQuery parsing XML problem

  • I'm using javascript to get my xml file from the server.

    I get all the file text if I write this:

    if (req.readyState == 4) {
    if (req.status == 200) {
    alert(req.responseText);
    }
    }


    I get "[object XMLDocument]" if I write this:

    if (req.readyState == 4) {
    if (req.status == 200) {
    alert(req.responseXML);
    }
    }


    But than it does nothing if I try this:

    if (req.readyState == 4) {
    if (req.status == 200) {
    alert(req.responseXML.find("Hello"));
    }
    }


    Hello it's the tag I'm trying to find.


    Any idea why is jQuery not finding my tag? How can I print all the xml file when I have XMLDocument Object (to see if it's empty).

    Thanks in advance