GetElementsByTagName("") - is not supported by XmlHttpRequest??
-
wrote on 22 Aug 2011, 15:55 last edited by
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?
-
wrote on 23 Jul 2012, 06:53 last edited by
This is already a bug: https://bugreports.qt-project.org/browse/QTBUG-19809
-
wrote on 23 Jul 2012, 09:48 last edited by
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;
}@:)