Results 1 to 2 of 2

Thread: Error while setting content in dom reader

  1. #1
    Join Date
    Jun 2015
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Error while setting content in dom reader

    Hey.. i am a newbie.. so please be patient..
    using xml and qt for first time.


    i am trying to read a xml using a dom reader, but it shows a error---

    MY XML---
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2.  
    3. -<Summary>
    4.  
    5. <no_of_blank_spaces>13</no_of_blank_spaces>
    6.  
    7. <no_of_blank_lines>8</no_of_blank_lines>
    8.  
    9. <no_of_words>16</no_of_words>
    10.  
    11. <no_of_lines_starting_with_hash>2</no_of_lines_starting_with_hash>
    12.  
    13. </Summary>
    To copy to clipboard, switch view to plain text mode 


    MY DOM READER CODE---


    Qt Code:
    1. void DOMReader::parseFile(QString fileName) {
    2.  
    3. QFile file(fileName);
    4.  
    5. //file.open(QIODevice::ReadOnly);
    6. if (!file.open(QIODevice::ReadOnly)) {
    7. qDebug() << "Not able to open the file";
    8. return;
    9. }
    10.  
    11. qDebug()<<"///////////////////////////"<<file.isOpen();----> [B]IT SHOWS OPEN here.[/B]
    12.  
    13. QString errMsg;
    14. int errLine;
    15. int errCol;
    16.  
    17.  
    18.  
    19.  
    20. if (!doc.setContent(&file,false,&errMsg,&errLine,&errCol)) {
    21. qDebug() << "errMsg : " << errMsg;
    22. qDebug() << "errLine : " << errLine;
    23. qDebug() << "errCol : " << errCol;
    24.  
    25. qDebug() << "Error in XML File format" <<endl;
    26. return;
    27. }
    28. QDomElement root = doc.documentElement();
    29. if (root.tagName() != "Summary") {
    30. qDebug() << "Error in root" << endl;
    31. return;
    32. }
    33. processRoot(root);
    34. return;
    35. }
    36.  
    37. void DOMReader::processRoot(QDomElement root)
    38. {
    39. qDebug()<< "***********in dom*********" << endl;
    40. }
    To copy to clipboard, switch view to plain text mode 



    I am getting a error as--:

    errorMSg:-"unexpected end of file"
    errLINe:1
    errCol:1
    Error in XML Format..




    kindly help me through..
    Last edited by anda_skoa; 12th June 2015 at 13:49. Reason: missing [code] tags

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Error while setting content in dom reader

    Your code, test file, and your error message do not match. Please copy and paste rather than retyping. Also, put your code between [code]...[/code] tags

    With your test file as posted:
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2.  
    3. -<Summary>
    4.  
    5. <no_of_blank_spaces>13</no_of_blank_spaces>
    6.  
    7. <no_of_blank_lines>8</no_of_blank_lines>
    8.  
    9. <no_of_words>16</no_of_words>
    10.  
    11. <no_of_lines_starting_with_hash>2</no_of_lines_starting_with_hash>
    12.  
    13. </Summary>
    To copy to clipboard, switch view to plain text mode 
    your code generates:
    Qt Code:
    1. /////////////////////////// true
    2. errMsg : "error occurred while parsing element"
    3. errLine : 3
    4. errCol : 1
    5. Error in XML File format
    To copy to clipboard, switch view to plain text mode 
    and it is the direct result of the 3rd line starting with a hyphen.

Similar Threads

  1. Replies: 1
    Last Post: 1st October 2012, 23:06
  2. QDialog setting maximum width to content
    By warchild in forum Qt Programming
    Replies: 1
    Last Post: 2nd April 2012, 14:08
  3. Exported PDF Drawing Error in Adobe Reader
    By BettaUseYoNikes in forum Qwt
    Replies: 0
    Last Post: 15th November 2011, 16:58
  4. Replies: 7
    Last Post: 3rd December 2010, 05:02
  5. lQtGuid4 error - Compiler setting problem
    By Kapil in forum Installation and Deployment
    Replies: 7
    Last Post: 10th February 2006, 09:30

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
  •  
Qt is a trademark of The Qt Company.