当前位置: 首页>>代码示例>>C++>>正文


C++ QDomNode::isDocument方法代码示例

本文整理汇总了C++中QDomNode::isDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::isDocument方法的具体用法?C++ QDomNode::isDocument怎么用?C++ QDomNode::isDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDomNode的用法示例。


在下文中一共展示了QDomNode::isDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isDocument

bool QDomNodeProto:: isDocument() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->isDocument();
  return false;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: findDomNodeScan

/**
 * @brief XmlEditWidgetPrivate::findDomNodeScan find the nearest match to a position
 * @param node
 * @param nodeTarget
 * @param lineSearched
 * @param columnSearched
 * @param lastKnownNode: last known "good" position
 * @return
 */
bool XmlEditWidgetPrivate::findDomNodeScan(QDomNode node, QDomNode nodeTarget, const int lineSearched, const int columnSearched, FindNodeWithLocationInfo &info)
{
    int row = node.lineNumber();
    int col = node.columnNumber();
    if(!node.isDocument()) {
        if((lineSearched == row) && (columnSearched == col)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }

        if((lineSearched == row) && (columnSearched == col)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }
        if((lineSearched == row) && (columnSearched < col)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }
        if((lineSearched < row)) {
            info.matchedNode = nodeTarget ;
            return true ;
        }
        if((lineSearched <= row)) {
            info.lastKnownNode = nodeTarget ;
        }

        if(node.nodeType() == QDomNode::ElementNode) {
            QDomElement element = node.toElement();
            QDomNamedNodeMap attributes = element.attributes();
            int numAttrs = attributes.length();
            for(int i = 0 ; i < numAttrs ; i++) {
                QDomNode node = attributes.item(i);
                QDomAttr attr = node.toAttr();
                if(findDomNodeScan(attr, nodeTarget, lineSearched, columnSearched, info)) {
                    return true;
                }
            } // for
        }
    }

    int nodes = node.childNodes().count();
    for(int i = 0 ; i < nodes ; i ++) {
        QDomNode childNode = node.childNodes().item(i) ;
        if(childNode.isText() || childNode.isCDATASection()) {
            if(findDomNodeScan(childNode, nodeTarget, lineSearched, columnSearched, info)) {
                return true;
            }
        } else {
            if(findDomNodeScan(childNode, childNode, lineSearched, columnSearched, info)) {
                return true ;
            }
        }
    }
    return false ;
}
开发者ID:ericsium,项目名称:qxmledit,代码行数:64,代码来源:validationresults.cpp

示例3: getChildByTag

QDomElement BaseXMLVisitor::getChildByTag(const char *name)
{

    //qDebug("BaseXMLVisitor::getChildByTag(%s): called", name );
    QDomNode mainNode = mNodePath.back();
    if (mainNode.isNull()) {
        qDebug("  BaseXMLVisitor::getChildByTag(): path is null");
        return QDomElement();
    }

    if (mainNode.isElement())
    {
//        qDebug("  BaseXMLVisitor::getChildByTag(): path ends with element");

        QDomElement mainElement = mainNode.toElement();
        QDomNodeList nodesWithTag = mainElement.elementsByTagName(name);
        if (nodesWithTag.length() != 0)
        {
//            qDebug("  BaseXMLVisitor::getChildByTag(): found sub element");
            return nodesWithTag.at(0).toElement();
        }
        return QDomElement();
    }

    if (mainNode.isDocument())
    {
//        qDebug("  BaseXMLVisitor::getChildByTag(): path ends with document");
        QDomDocument mainDocument = mainNode.toDocument();
        QDomNodeList nodesWithTag = mainDocument.elementsByTagName(name);
        if (nodesWithTag.length() != 0)
        {
//            qDebug("  BaseXMLVisitor::getChildByTag(): found sub element");
            return nodesWithTag.at(0).toElement();
        }
        return QDomElement();
    }

    return QDomElement();
}
开发者ID:Aldrog,项目名称:corecvs,代码行数:39,代码来源:baseXMLVisitor.cpp

示例4: 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();
    }
}
开发者ID:lawrence-iviani,项目名称:DataHandler,代码行数:67,代码来源:readandwritexml.cpp


注:本文中的QDomNode::isDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。