{
tablewidget = table;
table_item = 0;
}
{
if (qName == "statement"){
tablewidget->insertRow(1);
if(qName == "Condition")
{
QString str_id
= attributes.
value("text");
qDebug()<<str_id;
}
else if(qName == "action")
{
QString str_id
= attributes.
value("text");
qDebug()<<str_id;
}
else if(qName == "text")
currenttext.clear();
}
return true;
}
bool Xmlhandler
::characters(const QString &str
) {
currenttext += str;
return true;
}
{
if(qName == "statement"){
if (qName == "Condition") {
if (qName == "page") {
table_item->setText(currenttext);
tablewidget->setItem(0, 0, table_item);
}
}
if (qName == "action") {
if (qName == "page") {
table_item->setText(currenttext);
tablewidget->setItem(0, 1, table_item);
}
}
}
return true;
}
{
"%2:\n%3.").arg(exception.lineNumber()).arg(exception.columnNumber()).arg(exception.message()));
return false;
}
Xmlhandler::Xmlhandler(QTableWidget *table)
{
tablewidget = table;
table_item = 0;
}
bool Xmlhandler::startElement(const QString &, const QString &, const QString &qName,const QXmlAttributes &attributes)
{
if (qName == "statement"){
tablewidget->insertRow(1);
if(qName == "Condition")
{
QString str_id = attributes.value("text");
qDebug()<<str_id;
table_item = new QTableWidgetItem();
}
else if(qName == "action")
{
QString str_id = attributes.value("text");
qDebug()<<str_id;
table_item = new QTableWidgetItem();
}
else if(qName == "text")
currenttext.clear();
}
return true;
}
bool Xmlhandler::characters(const QString &str)
{
currenttext += str;
return true;
}
bool Xmlhandler::endElement(const QString &,const QString &,const QString &qName)
{
if(qName == "statement"){
if (qName == "Condition") {
if (qName == "page") {
table_item->setText(currenttext);
tablewidget->setItem(0, 0, table_item);
}
}
if (qName == "action") {
if (qName == "page") {
table_item->setText(currenttext);
tablewidget->setItem(0, 1, table_item);
}
}
}
return true;
}
bool Xmlhandler::fatalError(const QXmlParseException &exception)
{
QMessageBox::warning(0, QObject::tr("SAX Handler"),QObject::tr("Parse error at line %1, column "
"%2:\n%3.").arg(exception.lineNumber()).arg(exception.columnNumber()).arg(exception.message()));
return false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks