PDA

View Full Version : XML parsing



systemz89
29th December 2007, 16:17
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 :)

wysota
29th December 2007, 16:48
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.

high_flyer
29th December 2007, 16:54
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 ;)

systemz89
29th December 2007, 17:48
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:



#include "structureparser.h"
#include <QFile>
#include <QXmlInputSource>
#include <QXmlSimpleReader>
#include <QDebug>
int main( int argc, char **argv ) {
QFile xmlFile( "contacts.xml" );
QXmlInputSource source( &xmlFile );
StructureParser handler;
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
reader.parse( source );


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... :crying:

jacek
29th December 2007, 18:31
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.