本文整理汇总了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;
}
示例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 ;
}
示例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();
}
示例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();
}
}