⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 structureparser.cpp

📁 关于xml文件解析的一个例子
💻 CPP
字号:
/*$Id: qt/examples/xml/tagreader-with-features/structureparser.cpp   2.3.10   edited 2005-01-24 $*/#include "structureparser.h"#include <qstring.h>#include <qlistview.h> StructureParser::StructureParser( QListView * t )                : QXmlDefaultHandler() {    table = t;    table->setSorting( -1 ); // no sorting    table->addColumn( "Qualified name" );    table->addColumn( "Namespace" );}bool StructureParser::startDocument(){    return TRUE;}bool StructureParser::startElement( const QString& namespaceURI, const QString& ,                                     const QString& qName,                                     const QXmlAttributes& attributes){    QListViewItem * element;    if ( ! stack.isEmpty() ){	element = new QListViewItem( stack.top(), qName, namespaceURI );    } else {	element = new QListViewItem( table, qName, namespaceURI );    }    stack.push( element );    element->setOpen( TRUE );    if ( attributes.length() > 0 ){        QListViewItem * attribute;	for ( int i = 0 ; i < attributes.length(); i++ ){	    attribute = new QListViewItem( element,	                                   attributes.qName(i), 	                                   attributes.uri(i) ); 	}          }     return TRUE;}bool StructureParser::endElement( const QString&, const QString&, const QString& ){    stack.pop();    return TRUE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -