本文整理汇总了C++中QDomNode::isProcessingInstruction方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::isProcessingInstruction方法的具体用法?C++ QDomNode::isProcessingInstruction怎么用?C++ QDomNode::isProcessingInstruction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::isProcessingInstruction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doExecute
void XBELImportCommand::doExecute(const KBookmarkGroup &/*bkGroup*/) {
// check if already open first???
KBookmarkManager *pManager = KBookmarkManager::managerForFile(m_fileName, QString());
QDomDocument doc = GlobalBookmarkManager::self()->mgr()->internalDocument();
// get the xbel
QDomNode subDoc = pManager->internalDocument().namedItem("xbel").cloneNode();
if (subDoc.isProcessingInstruction())
subDoc = subDoc.nextSibling();
if (subDoc.isDocumentType())
subDoc = subDoc.nextSibling();
if (subDoc.nodeName() != "xbel")
return;
if (!folder().isEmpty()) {
// transform into folder
subDoc.toElement().setTagName("folder");
// clear attributes
QStringList tags;
for (int i = 0; i < subDoc.attributes().count(); i++)
tags << subDoc.attributes().item(i).toAttr().name();
for (QStringList::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
subDoc.attributes().removeNamedItem((*it));
subDoc.toElement().setAttribute("icon", m_icon);
// give the folder a name
QDomElement textElem = doc.createElement("title");
subDoc.insertBefore(textElem, subDoc.firstChild());
textElem.appendChild(doc.createTextNode(folder()));
}
// import and add it
QDomNode node = doc.importNode(subDoc, true);
if (!folder().isEmpty()) {
GlobalBookmarkManager::self()->root().internalElement().appendChild(node);
m_group = KBookmarkGroup(node.toElement()).address();
} else {
QDomElement root = GlobalBookmarkManager::self()->root().internalElement();
QList<QDomElement> childList;
QDomNode n = subDoc.firstChild().toElement();
while (!n.isNull()) {
QDomElement e = n.toElement();
if (!e.isNull())
childList.append(e);
n = n.nextSibling();
}
QList<QDomElement>::Iterator it = childList.begin();
QList<QDomElement>::Iterator end = childList.end();
for (; it!= end ; ++it)
root.appendChild((*it));
}
}
示例2: isProcessingInstruction
bool QDomNodeProto:: isProcessingInstruction() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->isProcessingInstruction();
return false;
}
示例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();
}
}