Results 1 to 7 of 7

Thread: reading xml file in qml(javascript)

  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default reading xml file in qml(javascript)

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: reading xml file in qml(javascript)

    QML can't access files directly. You have to do it from C++.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: reading xml file in qml(javascript)

    so what is to done with XMLHttpRequest???

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: reading xml file in qml(javascript)

    Quote Originally Posted by alizadeh91 View Post
    so what is to done with XMLHttpRequest???
    It's an equivalent of AJAX, if it fits your purpose, you can use it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: reading xml file in qml(javascript)

    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
    Last edited by alizadeh91; 14th September 2012 at 17:13.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: reading xml file in qml(javascript)

    A node has an attributes method (or property?) that returns a list of attributes of a given node. It is all in XMLHttpRequest docs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: reading xml file in qml(javascript)

    yeah that works thanks

Similar Threads

  1. QWebView Reading content shown by Javascript
    By lhg in forum Qt Programming
    Replies: 0
    Last Post: 14th October 2011, 19:00
  2. calling Included JavaScript file in QML
    By et3rnal in forum Qt Quick
    Replies: 2
    Last Post: 1st September 2011, 04:23
  3. Replies: 9
    Last Post: 29th November 2010, 12:12
  4. External Javascript file not loading initially
    By bkudrle in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2009, 17:05
  5. Replies: 1
    Last Post: 25th July 2008, 23:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.