Results 1 to 5 of 5

Thread: XML parsing

  1. #1
    Join Date
    Dec 2007
    Posts
    9
    Thanked 1 Time in 1 Post

    Default XML parsing

    Hello!
    How can I parse an XML file... I trying it for a while but I don't realised nothing
    I tried with this book, but I didn't really understand it:

    "An Introduction to Design Patterns in C++ with Qt 4" by Alan*Ezust, Paul*Ezust
    ...............................................
    Publisher: Prentice Hall
    Pub Date: August 31, 2006
    Print ISBN-10: 0-13-187905-7
    Print ISBN-13: 978-0-13-187905-8
    Pages: 656

    How can I resolve this situation?

    Here is the XML file what I want to parse and edit... And here is what I managed to realise...

    Thanks for all help
    Attached Files Attached Files

  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: XML parsing

    I don't see any code relevant to actually parsing the file in your application. Am I missing something? If not, then you'll want to take a look at QDomDocument and QXmlStreamReader.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: XML parsing

    I don't see in your code any thing that does xml parsing... can you post the method that you made for parsing XML?
    In addtion, why don't you use the Qt XML classes, you can start by readin the docs for QXmlSimpleReader
    edit: ah, again beat to it by Witek
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Dec 2007
    Posts
    9
    Thanked 1 Time in 1 Post

    Default Re: XML parsing

    There is no parsing code in application. This is my problem... I try to parse xml files in a different (probe) application where I didn't manage it

    Last try was this:

    Qt Code:
    1. #include "structureparser.h"
    2. #include <QFile>
    3. #include <QXmlInputSource>
    4. #include <QXmlSimpleReader>
    5. #include <QDebug>
    6. int main( int argc, char **argv ) {
    7. QFile xmlFile( "contacts.xml" );
    8. QXmlInputSource source( &xmlFile );
    9. StructureParser handler;
    10. reader.setContentHandler( &handler );
    11. reader.parse( source );
    To copy to clipboard, switch view to plain text mode 

    I always get an error related to "structureparser.h"... I tried with adding the line QT += xml to .pro file but not helped me Even if I get working this code I cannot continue...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: XML parsing

    Quote Originally Posted by systemz89 View Post
    I always get an error related to "structureparser.h"...
    This file isn't a part of Qt. It must be some code from the book you have mentioned.

    If you want a working example check the dombookmarks and saxbookmarks examples that come with Qt.

Similar Threads

  1. Parsing Files
    By JayJay in forum Qt Programming
    Replies: 13
    Last Post: 20th August 2007, 20:01
  2. parsing using QDOM
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2007, 13:46
  3. XML Parsing in Qt 3.3
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2007, 19:54
  4. Config file parsing
    By Vash5556 in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 00:11
  5. HTML Parsing
    By awalesminfo in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2006, 12:31

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.