bool startElement( const QString& /*namespaceURI*/, const QString& localName, const QString& qName, const QXmlAttributes& atts ) { // Some Parent Elements have special meanings if ( stack.isEmpty() ) { if ( qName == "definitions" ) return true; // Include another file if ( qName == "include" ) { QString value = atts.value( "file" ); impl->imports.push_back( value ); return true; } } cElement* element = new cElement; element->setName( localName.latin1() ); element->copyAttributes( atts ); // Child Element ? if ( stack.count() > 0 ) { cElement* parent = stack.current(); // Pop the potential parent parent->addChild( element ); // Add the child to it's parent element->setParent( parent ); } stack.push( element ); // Push our element (there may be children) return true; }
virtual ~cXmlHandler() { while ( !elements.isEmpty() ) { cElement *parent; while ( !elements.isEmpty() && elements.current() != NULL ) { parent = elements.pop(); } delete parent; while ( !elements.isEmpty() && elements.current() == NULL ) { elements.pop(); } } }
bool characters( const QString& ch ) { if ( !elements.isEmpty() ) { cElement *element = elements.current(); if ( element ) element->setText( element->text() + ch ); } return true; }