PDA

View Full Version : reading xml file in qml(javascript)



alizadeh91
13th September 2012, 15:29
How can i read xml file in qml(javascript)??????? i don't want to use XmlListModel in qml. I want to directly read xml in javascript

wysota
13th September 2012, 15:32
QML can't access files directly. You have to do it from C++.

alizadeh91
13th September 2012, 16:01
so what is to done with XMLHttpRequest???

wysota
13th September 2012, 19:47
so what is to done with XMLHttpRequest???

It's an equivalent of AJAX, if it fits your purpose, you can use it.

alizadeh91
14th September 2012, 17:13
Thanks wysota but i have problem with XMLHttpRequest:
I have XML file and i want to get an attribute value. I've get the node and in the web i remember that I've used to use getAttributeNode or getAttribute to get an Attribute Value. But it seems that some API of XMLHTTPRequest have not implemented in qml.
Anyway how can i get an Attribute Value of a node in qml????

when i use one of above functions i get following error:
TypeError: Result of expression 'a.childNodes[i].getAttribute' [undefined] is not a function.
[this error is same for : getAttributeNode ]

Additionally there's an example in Qt's examples for XMLHttpRequest but it is so simple and it just gets name of childs.

Added after 1 41 minutes:

Can't anybody guide me?? the qt documentation is so poor about this

wysota
14th September 2012, 18:26
A node has an attributes method (or property?) that returns a list of attributes of a given node. It is all in XMLHttpRequest docs.

alizadeh91
14th September 2012, 18:45
yeah that works :) thanks