本文整理汇总了C++中QDomDocument::childNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::childNodes方法的具体用法?C++ QDomDocument::childNodes怎么用?C++ QDomDocument::childNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::childNodes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
QList<QDomElement> XmlUtils::FetchElementsFromDocument(QDomDocument xmls)
{
QList<QDomElement> results;
int index = 0;
while (index < xmls.childNodes().count())
{
QDomNode node = xmls.childNodes().at(index++);
RecursiveFetch(node, &results);
}
return results;
}
示例2: childNodes
QDomNodeList QDomDocumentProto::childNodes() const
{
QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
if (item)
return item->childNodes();
return QDomNodeList();
}
示例3: init
void InterpreterElementImpl::init(QRectF &contents, PortFactoryInterface const &portFactory
, QList<PortInterface *> &ports, LabelFactoryInterface &labelFactory
, QList<LabelInterface *> &labels, SdfRendererInterface *renderer, ElementRepoInterface *elementRepo)
{
Q_UNUSED(elementRepo);
if (mId.element() == "MetaEntityNode") {
mGraphics.setContent(mEditorRepoApi->stringProperty(mId, "shape"));
QDomDocument classDoc;
QDomElement sdfElement = mGraphics.firstChildElement("graphics").firstChildElement("picture");
classDoc.appendChild(classDoc.importNode(sdfElement, true));
if (!classDoc.childNodes().isEmpty()) {
mRenderer = renderer;
mRenderer->load(classDoc);
}
int width = 0;
int height = 0;
if (!sdfElement.isNull()) {
width = sdfElement.attribute("sizex").toInt();
height = sdfElement.attribute("sizey").toInt();
}
initPointPorts(portFactory, ports, width, height);
initLinePorts(portFactory, ports, width, height);
contents.setWidth(width);
contents.setHeight(height);
initLabels(width, height, labelFactory, labels);
}
}
示例4: initializeDocument
void SxeSession::initializeDocument(const QDomDocument &doc) {
importing_ = true;
// reset the document
doc_ = QDomDocument();
foreach(SxeRecord* meta, recordByNodeId_.values())
meta->deleteLater();
// recordByNode_.clear();
recordByNodeId_.clear();
queuedIncomingEdits_.clear();
queuedOutgoingEdits_.clear();
// import prolog
doc_.setContent(parseProlog(doc));
// import other nodes
// create all nodes recursibely from root
QDomNodeList children = doc.childNodes();
for(int i = 0; i < children.size(); i++) {
// skip the XML declaration <?xml ...?> because it isn't a processing instruction
if(!(children.at(i).isProcessingInstruction() && children.at(i).toProcessingInstruction().target().toLower() == "xml"))
generateNewNode(children.at(i), QString(), i);
}
importing_ = false;
}
示例5: OnTick
void UpdateForm::OnTick()
{
if (!this->qData->IsProcessed())
{
return;
}
QDomDocument r;
r.setContent(this->qData->Result->Data);
QDomNodeList l = r.elementsByTagName("obsolete");
if (l.count() == 0)
{
// there is no new version of huggle
this->qData->UnregisterConsumer("updater");
this->t->stop();
return;
} else
{
QString version = l.at(0).toElement().text();
/// \todo LOCALIZE ME
QString info = "New version of huggle is available: version " + version;
l = r.elementsByTagName("info");
if (l.count() > 0)
{
// we don't know how to update o.O
info = l.at(0).toElement().text();
this->ui->pushButton->setEnabled(false);
info = info.replace("$LATESTHUGGLE", version);
this->ui->label->setText(info);
this->show();
this->qData->UnregisterConsumer("updater");
this->t->stop();
return;
} else
{
// get the instructions
l = r.childNodes();
int id = 0;
while (id < l.count())
{
QDomElement element = l.at(0).toElement();
id++;
if (element.tagName() == "download")
{
if (!element.attributes().contains("target"))
{
Syslog::HuggleLogs->Log("WARNING: Invalid updater instruction: download is missing target, ingoring the update");
this->qData->UnregisterConsumer("updater");
this->t->stop();
return;
}
this->Instructions.append("download " + element.text() + " " + element.attribute("target"));
}
if (element.tagName() == "exec")
{
bool root = false;
if (element.attributes().contains("root"))
{
if (element.attribute("root") == "true")
{
root = true;
}
}
if (root)
{
this->Instructions.append("roexec " + element.text());
} else
{
this->Instructions.append("exec " + element.text());
}
}
}
}
this->ui->label->setText(info);
this->show();
}
this->qData->UnregisterConsumer("updater");
this->t->stop();
}
示例6: verify
TestResult::Status TestBaseLine::verify(const QString &serializedInput) const
{
switch(m_type)
{
case SchemaIsValid:
/* Fall through. */
case Text:
{
if(serializedInput == details())
return TestResult::Pass;
else
return TestResult::Fail;
}
case Fragment:
/* Fall through. */
case XML:
{
/* Read the baseline and the serialized input into two QDomDocuments, and compare
* them deeply. We wrap fragments in a root node such that it is well-formed XML.
*/
QDomDocument output;
{
/* The reason we put things into a QByteArray and then parse it through QXmlSimpleReader, is that
* QDomDocument does whitespace stripping when calling setContent(QString). In other words,
* this workarounds a bug. */
QXmlInputSource source;
source.setData((m_type == XML ? serializedInput : QLatin1String("<r>") +
serializedInput +
QLatin1String("</r>")).toUtf8());
QString outputReadingError;
QXmlSimpleReader reader;
reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true);
const bool success = output.setContent(&source,
&reader,
&outputReadingError);
if(!success)
return TestResult::Fail;
Q_ASSERT(success);
}
QDomDocument baseline;
{
QXmlInputSource source;
source.setData((m_type == XML ? details() : QLatin1String("<r>") +
details() +
QLatin1String("</r>")).toUtf8());
QString baselineReadingError;
QXmlSimpleReader reader;
reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true);
const bool success = baseline.setContent(&source,
&reader,
&baselineReadingError);
if(!success)
return TestResult::Fail;
/* This piece of code workaround a bug in QDom, which treats XML prologs as processing
* instructions and make them available in the tree as so. */
if(m_type == XML)
{
/* $doc/r/node() */
const QDomNodeList children(baseline.childNodes());
const int len = children.length();
for(int i = 0; i < len; ++i)
{
const QDomNode &child = children.at(i);
if(child.isProcessingInstruction() && child.nodeName() == QLatin1String("xml"))
{
baseline.removeChild(child);
break;
}
}
}
Q_ASSERT_X(baselineReadingError.isNull(), Q_FUNC_INFO,
qPrintable((QLatin1String("Reading the baseline failed: ") + baselineReadingError)));
}
if(isDeepEqual(output, baseline))
return TestResult::Pass;
else
{
pDebug() << "FAILURE:" << output.toString() << "is NOT IDENTICAL to(baseline):" << baseline.toString();
return TestResult::Fail;
}
}
case Ignore:
return TestResult::Pass;
case Inspect:
return TestResult::NotTested;
//.........这里部分代码省略.........
示例7: setShowDockIcon
void QNapiConfig::setShowDockIcon(bool show)
{
QString infoPlistPath = QFileInfo(QApplication::applicationDirPath() + "/../Info.plist").canonicalFilePath();
QFile plistFile(infoPlistPath);
QDomDocument doc;
if(!doc.setContent(&plistFile) || !doc.hasChildNodes())
return;
QDomNodeList nodes = doc.childNodes();
QDomNode node;
int i;
for(i = 0; i < nodes.size(); ++i)
{
node = nodes.at(i);
if(node.nodeName() == "plist")
break;
}
if((i == nodes.size()) || !node.hasChildNodes())
return;
nodes = node.childNodes();
for(i = 0; i < nodes.size(); ++i)
{
node = nodes.at(i);
if(node.nodeName() == "dict")
break;
}
if((i == nodes.size()) || !node.hasChildNodes())
return;
nodes = node.childNodes();
for(i = 0; i < nodes.size(); ++i)
{
node = nodes.at(i);
QString subText;
if(node.hasChildNodes())
{
subText = node.childNodes().at(0).toText().data();
}
if(subText == "LSUIElement")
break;
}
if(i >= nodes.size())
return;
node = node.nextSibling();
node.toElement().setTagName(show ? "false" : "true");
QString modifiedContent = doc.toString(4);
plistFile.close();
if(!plistFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
return;
QTextStream plistStream(&plistFile);
plistStream << modifiedContent;
plistFile.close();
}
示例8: showDockIcon
bool QNapiConfig::showDockIcon()
{
const bool show_default = true;
QString infoPlistPath = QFileInfo(QApplication::applicationDirPath() + "/../Info.plist").canonicalFilePath();
QFile plistFile(infoPlistPath);
QDomDocument doc;
if(!doc.setContent(&plistFile))
return show_default;
if(!doc.hasChildNodes())
return show_default;
QDomNodeList nodes = doc.childNodes();
QDomNode node;
int i;
for(i = 0; i < nodes.size(); ++i)
{
node = nodes.at(i);
if(node.nodeName() == "plist")
break;
}
if(i == nodes.size())
return show_default;
if(!node.hasChildNodes())
return show_default;
nodes = node.childNodes();
for(i = 0; i < nodes.size(); ++i)
{
node = nodes.at(i);
if(node.nodeName() == "dict")
break;
}
if(i == nodes.size())
return show_default;
if(!node.hasChildNodes())
return show_default;
nodes = node.childNodes();
for(i = 0; i < nodes.size(); ++i)
{
node = nodes.at(i);
QString subText;
if(node.hasChildNodes())
{
subText = node.childNodes().at(0).toText().data();
}
if(subText == "LSUIElement")
break;
}
if(i < nodes.size())
{
node = node.nextSibling();
return (node.nodeName() != "true");
}
return show_default;
}