本文整理汇总了C++中QDomNode::isEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::isEntity方法的具体用法?C++ QDomNode::isEntity怎么用?C++ QDomNode::isEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::isEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isEntity
bool QDomNodeProto:: isEntity() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->isEntity();
return false;
}
示例2: on_btn_all_clicked
void MainWindow::on_btn_all_clicked()
{
ui->listWidget->clear();
QFile file("my.xml");
if(!file.open(QIODevice::ReadOnly))
{
return;
}
QDomDocument doc;
QString errstr;
int errline;
int errrow;
if(!doc.setContent(&file, true, &errstr, &errline, &errrow))
{
qDebug() << errstr<< errline<< errrow;
file.close();
return;
}
file.close();
QDomElement domelem = doc.documentElement();
QDomNode n = domelem.firstChild();
if(!n.isNull())
{
if(n.isEntity())
{
QDomElement e = n.toElement();
ui->listWidget->addItem(e.tagName() +e.attribute(tr("编号")));
QDomNodeList list = e.childNodes();
for(int i=0; i<list.count(); i++)
{
QDomNode node = list.at(i);
if(node.isElement())
{
ui->listWidget->addItem(" " + node.toElement().tagName() + " :" + node.toElement().text());
}
}
}
n = n.nextSibling();
}
}
示例3: parseEntry
void ReadAndWriteXML::parseEntry(const QDomElement &element, QTreeWidgetItem *parent, int parentLevel)
{
// item->setText(0, element.attribute("term"));
QDomNode node = element.firstChild();
while (!node.isNull()) {
//qDebug() << "DomParser::parseEntry node " << node.toElement().tagName();
// qDebug() << "DomParser::parseEntry parsing node " << node.nodeName();
if (node.isElement()) {
//qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is element ";
QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
parseEntry(node.toElement(), childitem,++parentLevel);
QString _attr="";
if (node.hasAttributes()) {
childitem=new QTreeWidgetItem(childitem, QStringList(QString("Attributes node %1").arg(node.nodeName())));
parseAttribute(node.attributes(), childitem, parentLevel);
}
node = node.nextSibling();
continue;
}
if (node.isCDATASection()) {
//qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is CDATASection --" << node.toText().data() << "--";
new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
node = node.nextSibling();
continue;
}
if (node.isComment()) {
//qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is comment --" << node.toText().data() << "--";
new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
node = node.nextSibling();
continue;
}
if (node.isText()) {
//qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " text --" << node.toText().data() << "--";
new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
node = node.nextSibling();
continue;
}
if (node.isDocument()) {
//qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is document ";
QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
parseEntry(node.toElement(), childitem,++parentLevel);
node = node.nextSibling();
continue;
}
if (node.isDocumentType()) {
qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is document type";
QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
parseEntry(node.toElement(), childitem,++parentLevel);
node = node.nextSibling();
continue;
}
if (node.isDocumentFragment()) {
qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is document fragment";
QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
parseEntry(node.toElement(), childitem,++parentLevel);
node = node.nextSibling();
continue;
}
if (node.isEntity() || node.isEntityReference () || node.isNotation () || node.isProcessingInstruction ()) {
qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is not supported";
node = node.nextSibling();
continue;
}
node = node.nextSibling();
}
}