Results 1 to 6 of 6

Thread: XML Parsing in Qt 3.3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: XML Parsing in Qt 3.3

    Could you show us your InterceptReader class? At least the error handling routines...

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 8 Times in 4 Posts

    Red face Re: XML Parsing in Qt 3.3

    Qt Code:
    1. bool InterceptReader::fatalError( const QXmlParseException &exception )
    2. {
    3. qWarning( "Line %d, column %d: %s", exception.lineNumber( ),
    4. exception.columnNumber( ), exception.message( ).ascii( ) );
    5. return false;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. bool InterceptReader::startElement( const QString &namespaceURI,
    2. const QString &localName,
    3. const QString &qName,
    4. const QXmlAttributes &attribs )
    5. {
    6. fprintf( stderr, "start element = %s\n", qName.ascii( ) );
    7. if( qName == QString( "ref_event" ) )
    8. {
    9. mOpenElement = qName;
    10. }
    11. else if( qName == QString( "dif_event" ) )
    12. {
    13. mOpenElement = qName;
    14. }
    15. return true;
    16. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. bool InterceptReader::characters( const QString &str )
    2. {
    3. if( mOpenElement == QString( "ref_event" ) )
    4. {
    5. mRefEventId= str;
    6. }
    7. else if( mOpenElement == QString( "dif_event" ) )
    8. {
    9. mDiffEventId= str;
    10. }
    11. return true;
    12. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. bool InterceptReader::endElement( const QString &namespaceURI,
    2. const QString &localName,
    3. const QString &qName )
    4. {
    5. fprintf( stderr, "end element = %s\n", qName.ascii( ) );
    6. if( qName == QString( "ref_event" ) )
    7. {
    8. mOpenElement = QString( "" );
    9. }
    10. else if( qName == QString( "dif_event" ) )
    11. {
    12. mOpenElement = QString( "" );
    13. }
    14. return true;
    15. }
    To copy to clipboard, switch view to plain text mode 

    Like I said this is more of a test right now to make sure I can parse through the XML and grab certain items and later I will implement more of what I want to do with them. But this is my basic XML parser. Thanks for your continued help!

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    15
    Thanked 21 Times in 16 Posts

    Default Re: XML Parsing in Qt 3.3

    what is reader.parse( &file ) value?

  4. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 8 Times in 4 Posts

    Red face Re: XML Parsing in Qt 3.3

    What do you mean by
    what is reader.parse( &file ) value?
    It returns false if that is what you mean?

    I have run my code through DBX and my stack's last 6 lines looks like
    Qt Code:
    1. reader.parse( &file )
    2. QXmlSimpleReader::parseBeginOrContinue
    3. QXmlSimpleReader::parseProlog
    4. QXmlSimpleReader::unexpectedEof
    5. QXmlSimpleReader::reportParseError
    6. InterceptReader::fatalError
    To copy to clipboard, switch view to plain text mode 

    Thanks again!

  5. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 8 Times in 4 Posts

    Wink [SOLVED] Re: XML Parsing in Qt 3.3

    I found my problem at least as to why I got my error. My XMLs were in a different directory than my executable and when getting a QDir, using the [] operator only returned the filename and when I created the QFile I needed to make sure to include the actual path to the files when giving the filename to create the QFile. Now that I give the path/filename the files don't error out. Thanks for your help anyways!

Similar Threads

  1. Parsing XML file
    By Djony in forum Qt Programming
    Replies: 7
    Last Post: 8th January 2007, 15:03
  2. parsing QtableWidget from a QStackedWidget
    By rosmarcha in forum Qt Programming
    Replies: 10
    Last Post: 13th October 2006, 14:36
  3. Config file parsing
    By Vash5556 in forum Qt Programming
    Replies: 2
    Last Post: 10th September 2006, 23:11
  4. HTML Parsing
    By awalesminfo in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2006, 11:31
  5. Trouble parsing using simple QRegExp
    By johnny_sparx in forum Qt Programming
    Replies: 4
    Last Post: 24th February 2006, 00:42

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.