GetElementsByTagName("") - is not supported by XmlHttpRequest??



  • Hello gents and ladies...
    So seems like XmlHttpRequest is gimped in QML and I can't use getElementsByTagName command to parse it?:(

    Is there other way around apart from the one I was using (by browsing through the Dom tree...:

    @
    doc.responseXML.documentElement.childNodes[1].childNodes[3].childNodes[1].childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[5].childNodes[1].childNodes[0].nodeValue
    @

    I would love to use:

    @
    doc.responseXML.documentElement.getElementsByTagName('thetag')
    @

    [EDIT: code formatting, please use @-tags, Volker]

    What is the workaround then?





  • You can implement your own getElementByTag name, something like:
    @function getElementsByTagName(rootElement, tagName) {
    var childNodes = rootElement.childNodes;
    var elements = [];
    for(var i = 0; i < childNodes.length; i++) {
    if(childNodes[i].nodeName === tagName) {
    elements.push(childNodes[i]);
    }
    }
    return elements;
    }@

    :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.