Results 1 to 1 of 1

Thread: DOM XML reader - Not getting any proper output

  1. #1
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default DOM XML reader - Not getting any proper output

    Hi,
    Below is my code & xml file. I am trying to read a xml file and store the contents. But its not working. Please help

    Qt Code:
    1. int ParseConfigFile::populateUserValues ( string &OS, string &dir, string &logPath )
    2. {
    3. QDomElement element;
    4.  
    5. QFile file("config_v1.xml");
    6.  
    7. if ( doc.setContent( file.readAll() ) == false )
    8. return 1;
    9.  
    10. element = doc.documentElement();
    11.  
    12. QDomNodeList list = element.childNodes();
    13. QDomElement firstChild = list.at(0).toElement(); // will return the first child
    14. QDomElement secondChild = list.at(1).toElement();
    15. QDomElement thirdChild = list.at(2).toElement();
    16.  
    17. QString s1,s2,s3;
    18. s1 = firstChild.text();
    19. s2 = secondChild.text();
    20. s3 = thirdChild.text();
    21.  
    22. OS = s1.toStdString();
    23. dir = s2.toStdString();
    24. logPath = s3.toStdString();
    25.  
    26. return 0;
    27. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

Similar Threads

  1. RSS Reader
    By numbat in forum Qt-based Software
    Replies: 2
    Last Post: 6th April 2011, 10:42
  2. Help with Binary reader in qt ???
    By rajji_saini in forum Qt Programming
    Replies: 7
    Last Post: 20th September 2010, 05:34
  3. reseting reader
    By uchennaanyanwu in forum Newbie
    Replies: 1
    Last Post: 1st August 2008, 20:28
  4. xml reader
    By mickey in forum General Programming
    Replies: 5
    Last Post: 13th January 2008, 18:37
  5. Qt + Barcode Reader
    By sunil.thaha in forum General Discussion
    Replies: 12
    Last Post: 13th November 2007, 12:13

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.