本文整理汇总了C++中QDomDocument::appendChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::appendChild方法的具体用法?C++ QDomDocument::appendChild怎么用?C++ QDomDocument::appendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::appendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// Prepare the XML file
QFile file("list.xml");
file.remove();
QDomDocument xml;
QDomNode declaration = xml.createProcessingInstruction("xml",QString("version=\"1.0\" encoding=\"UTF-8\""));
xml.insertBefore(declaration,xml.firstChild());
QDomComment comment = xml.createComment("Do not edit this file, it is regenerated automatically!");
xml.appendChild(comment);
QDomNode root = xml.createElement("files");
xml.appendChild(root);
// Liste tous les fichiers
QStringList liste;
QDirIterator it(".", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
if(QString(it.hasNext()).startsWith("./Assets/Modules/Custom_Civilizations_MCP/"))
{}
else{
// Add the file to the list
QDomElement entity = xml.createElement("file");
entity.appendChild(xml.createTextNode(it.next()));
entity.setAttribute("md5", checkMd5(it.next()));
root.appendChild(entity);
}
}
// Save the file
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
QTextStream ts(&file);
xml.save(ts, 4);
file.close();
return a.exec();
}
示例2: exportSldStyle
void QgsMapLayer::exportSldStyle( QDomDocument &doc, QString &errorMsg )
{
QDomDocument myDocument = QDomDocument();
QDomNode header = myDocument.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" );
myDocument.appendChild( header );
// Create the root element
QDomElement root = myDocument.createElementNS( "http://www.opengis.net/sld", "StyledLayerDescriptor" );
root.setAttribute( "version", "1.1.0" );
root.setAttribute( "xsi:schemaLocation", "http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
root.setAttribute( "xmlns:ogc", "http://www.opengis.net/ogc" );
root.setAttribute( "xmlns:se", "http://www.opengis.net/se" );
root.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
root.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
myDocument.appendChild( root );
// Create the NamedLayer element
QDomElement namedLayerNode = myDocument.createElement( "NamedLayer" );
root.appendChild( namedLayerNode );
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
if ( !vlayer )
{
errorMsg = tr( "Could not save symbology because:\n%1" )
.arg( "Non-vector layers not supported yet" );
return;
}
if ( !vlayer->writeSld( namedLayerNode, myDocument, errorMsg ) )
{
errorMsg = tr( "Could not save symbology because:\n%1" ).arg( errorMsg );
return;
}
doc = myDocument;
}
示例3: tr
bool
aBackup::dumpBase(const QString& rcfile, const QString& tmpDirName, int& prg, int totalSteps)
{
QDomDocument xml;
xml.setContent(QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
QDomElement root = xml.createElement( "AnanasDump" );
xml.appendChild( root );
aDatabase db;
if(db.init(rcfile))
{
emit (progress(++prg,totalSteps));
db.exchangeDataSystables ( xml, false );
emit (progress(++prg,totalSteps));
db.exchangeDataCatalogues( xml, false );
emit (progress(++prg,totalSteps));
db.exchangeDataDocuments ( xml, false );
emit (progress(++prg,totalSteps));
db.exchangeDataJournals ( xml, false );
emit (progress(++prg,totalSteps));
db.exchangeDataInfoRegisters ( xml, false );
emit (progress(++prg,totalSteps));
db.exchangeDataAccumulationRegisters ( xml, false );
db.exchangeDataUniques ( xml, true );
aLog::print(aLog::Debug, tr("aBackup dump tables ok"));
}
else
{
setLastError(tr("Can't connect to database"));
aLog::print(aLog::Error, tr("aBackup init rc file %1").arg(rcfile));
db.done();
return true;
}
qApp->processEvents();
emit (progress(++prg,totalSteps));
db.done();
if(writeXml(tmpDirName+"/content.xml",xml)==true)
{
setLastError(tr("Can't write content.xml"));
aLog::print(aLog::Error, tr("aBackup write content.xml"));
return true;
}
else
{
aLog::print(aLog::Info, tr("aBackup dump base to xml compleet"));
}
return false;
}
示例4: saveXML
void VCLabel_Test::saveXML()
{
QLCFixtureDefCache fdc;
Doc doc(this, fdc);
OutputMap om(this, 4);
InputMap im(this, 4);
MasterTimer mt(this, &om);
QWidget w;
VCLabel label(&w, &doc, &om, &im, &mt);
label.setCaption("Simo Kuassimo");
QDomDocument xmldoc;
QDomElement root = xmldoc.createElement("TestRoot");
xmldoc.appendChild(root);
QVERIFY(label.saveXML(&xmldoc, &root) == true);
QDomNode node = root.firstChild();
QVERIFY(node.nextSibling().isNull() == true);
QCOMPARE(node.toElement().tagName(), QString("Label"));
QCOMPARE(node.toElement().attribute("Caption"), QString("Simo Kuassimo"));
QVERIFY(node.firstChild().isNull() == false);
int appearance = 0, windowstate = 0;
node = node.firstChild();
while (node.isNull() == false)
{
QDomElement tag = node.toElement();
if (tag.tagName() == QString("Appearance"))
{
appearance++;
}
else if (tag.tagName() == QString("WindowState"))
{
windowstate++;
}
else
{
qDebug() << xmldoc.toString();
QFAIL("Unexpected tag in XML output!");
}
node = node.nextSibling();
}
QCOMPARE(appearance, 1);
QCOMPARE(windowstate, 1);
}
示例5: buildXMLDescription
/* private slots */
void CreateVirtNetwork_Adv::buildXMLDescription()
{
QDomDocument doc;
//qDebug()<<doc.toString();
QDomElement _xmlDesc, _name, _uuid;
QDomText data;
_xmlDesc = doc.createElement("network");
if ( ipv6->isChecked() ) {
_xmlDesc.setAttribute("ipv6", "yes");
};
_xmlDesc.setAttribute(
"trustGuestRxFilters",
(trustGuestRxFilters->isChecked())? "yes":"no");
_name = doc.createElement("name");
data = doc.createTextNode(networkName->text());
_name.appendChild(data);
_uuid = doc.createElement("uuid");
data = doc.createTextNode(uuid->text());
_uuid.appendChild(data);
_xmlDesc.appendChild(_name);
_xmlDesc.appendChild(_uuid);
if ( bridgeWdg->isUsed() ) {
_xmlDesc.appendChild(
bridgeWdg->getDataDocument());
};
if ( domainWdg->isUsed() ) {
_xmlDesc.appendChild(
domainWdg->getDataDocument());
};
if ( forwardWdg->isUsed() ) {
_xmlDesc.appendChild(
forwardWdg->getDataDocument());
};
if ( addressingWdg->isUsed() ) {
_xmlDesc.appendChild(
addressingWdg->getDataDocument());
};
if ( QoSWdg->isUsed() ) {
_xmlDesc.appendChild(
QoSWdg->getDataDocument());
};
doc.appendChild(_xmlDesc);
bool read = xml->open();
if (read) xml->write(doc.toByteArray(4).data());
xml->close();
}
示例6: createItemRequest
TupProjectRequest TupRequestBuilder::createItemRequest(int sceneIndex, int layerIndex, int frameIndex, int itemIndex, QPointF point, TupProject::Mode spaceMode,
TupLibraryObject::Type type, int actionId, const QVariant &arg, const QByteArray &data)
{
QDomDocument doc;
QDomElement root = doc.createElement("project_request");
QDomElement scene = doc.createElement("scene");
scene.setAttribute("index", sceneIndex);
QDomElement layer = doc.createElement("layer");
layer.setAttribute("index", layerIndex);
QDomElement frame = doc.createElement("frame");
frame.setAttribute("index", frameIndex);
QDomElement item = doc.createElement("item");
item.setAttribute("index", itemIndex);
QDomElement objectType = doc.createElement("objectType");
objectType.setAttribute("id", type);
QDomElement position = doc.createElement("position");
position.setAttribute("x", point.x());
position.setAttribute("y", point.y());
QDomElement space = doc.createElement("spaceMode");
space.setAttribute("current", spaceMode);
QDomElement action = doc.createElement("action");
action.setAttribute("id", actionId);
action.setAttribute("arg", arg.toString());
action.setAttribute("part", TupProjectRequest::Item);
TupRequestBuilder::appendData(doc, action, data);
root.appendChild(action);
item.appendChild(objectType);
item.appendChild(position);
item.appendChild(space);
frame.appendChild(item);
layer.appendChild(frame);
scene.appendChild(layer);
root.appendChild(scene);
doc.appendChild(root);
TupProjectRequest request(doc.toString(0));
return request;
}
示例7: createRequest
QString CRequestCreator::createRequest(QString method, QMap<QString, QString> parameters)
{
QDomDocument doc;
static const int indent = 4;
QDomElement methodCall = doc.createElement("methodCall");
QDomElement methodName = doc.createElement("methodName");
QDomElement params = doc.createElement("params");
QDomElement param = doc.createElement("param");
QDomElement value = doc.createElement("value");
QDomElement xmlStruct = doc.createElement("struct");
QDomText methodTextName = doc.createTextNode(method);
doc.appendChild(methodCall);
methodCall.appendChild(methodName);
methodName.appendChild(methodTextName);
methodCall.appendChild(params);
params.appendChild(param);
param.appendChild(value);
value.appendChild(xmlStruct);
for(QMap<QString, QString>::const_iterator it = parameters.begin(); it != parameters.end(); ++it)
{
QDomElement member = doc.createElement("member");
QDomElement name = doc.createElement("name");
QDomElement value = doc.createElement("value");
QDomElement xmlString = doc.createElement("string");
xmlStruct.appendChild(member);
member.appendChild(name);
QDomText parameterName = doc.createTextNode(it.key());
name.appendChild(parameterName);
member.appendChild(value);
value.appendChild(xmlString);
QDomText parameterValue = doc.createTextNode(it.value());
xmlString.appendChild(parameterValue);
}
QString result;
QTextStream os(&result);
doc.save(os, indent);
return result;
}
示例8: parseGroup
void QrsMetamodelLoader::parseGroup(const qrRepo::RepoApi &repo
, Metamodel &metamodel, const Id &diagram, const Id &id)
{
/// @todo: We should not use XML here, PatternType must not parse XML at all.
QDomDocument document;
QDomElement groupElement = document.createElement("group");
groupElement.setAttribute("name", validateName(repo, id));
groupElement.setAttribute("rootNode", stringProperty(repo, id, "rootNode"));
document.appendChild(groupElement);
parseGroupNodes(repo, groupElement, id);
PatternType *pattern = new PatternType(metamodel);
pattern->setXml(document.toString(4));
pattern->setDiagram(repo.name(diagram));
metamodel.addElement(*pattern);
}
示例9: save
/**
* \brief Convert all capabilities info to XML.
*/
void CapsRegistry::save()
{
// Generate XML
QDomDocument doc;
QDomElement capabilities = doc.createElement("capabilities");
doc.appendChild(capabilities);
QHash<QString,CapsInfo>::ConstIterator i = capsInfo_.constBegin();
for( ; i != capsInfo_.end(); i++) {
QDomElement info = i.value().toXml(&doc);
info.setAttribute("node",i.key());
capabilities.appendChild(info);
}
saveData(doc.toString().toUtf8());
}
示例10: sendRelVdRecState
void StreamMonitor::sendRelVdRecState(QString cameraId)
{
QDomDocument doc;
QDomProcessingInstruction instruction;
instruction = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
doc.appendChild(instruction);
QDomElement message = doc.createElement("message"); //<message>
doc.appendChild(message);
QDomElement type = doc.createElement("TYPE");//<TYPE>
QDomText typeStr = doc.createTextNode(QString::number(Send_Rec_State));
type.appendChild(typeStr);
message.appendChild(type);
QDomElement equip = doc.createElement("Equipment");//<Equipment>
message.appendChild(equip);
QDomElement camid = doc.createElement("CAMID");//<CAMID>
QDomText camidStr = doc.createTextNode(cameraId);
camid.appendChild(camidStr);
equip.appendChild(camid);
QString relVdRecXml = doc.toString();
sendMsg(relVdRecXml);
}
示例11: sendTypingNotification
bool MessageManager::sendTypingNotification( QString jid, bool start_typing )
{
if( !tlen_manager->isConnected() )
return false;
QDomDocument doc;
QDomElement typing_notification = doc.createElement( "m" );
typing_notification.setAttribute( "to", jid );
typing_notification.setAttribute( "tp", start_typing ? "t" : "u" );
doc.appendChild( typing_notification );
return tlen_manager->writeXml( doc );
}
示例12: getDataDocument
QDomDocument SecLabels::getDataDocument() const
{
QDomDocument doc;
if ( !useSecLabel->isChecked() ) return doc;
QDomElement _data;
_data = doc.createElement("data");
for (int i=0; i<list->count(); i++) {
QDomDocument _secLabel;
_secLabel.setContent(list->item(i)->text());
_data.appendChild(_secLabel);
};
doc.appendChild(_data);
//qDebug()<<doc.toString();
return doc;
}
示例13: i
QDomDocument
IPod::ScrobbleList::xml() const
{
QDomDocument xml;
QDomElement root = xml.createElement( "submissions" );
root.setAttribute( "product", "Twiddly" );
QListIterator<Track> i( *this );
while (i.hasNext())
root.appendChild( i.next().toDomElement( xml ) );
xml.appendChild( root );
return xml;
}
示例14: makeXml
void ImgToXml::makeXml(QString xmlFile) {
QDomDocument sampleXml ("NeuralNetworkSample");
QDomElement sample = sampleXml.createElement("sample");
sample.setAttribute("countOfImages", mCountOfImages);
sample.setAttribute("width", mImgSizeX);
sample.setAttribute("height", mImgSizeY);
sampleXml.appendChild(sample);
for (int i = 0; i < mCountOfImages; i++) {
sample.appendChild(saveImage(sampleXml, i));
}
QFile saveSample(xmlFile);
saveSample.open(QIODevice::WriteOnly);
QTextStream(&saveSample) << sampleXml.toString();
saveSample.close();
}
示例15: out
// clearDir(mWorkingDir);
foreach (LogicObject *object, objects) {
QString filePath = createDirectory(object->id());
QDomDocument doc;
QDomElement root = doc.createElement("LogicObject");
doc.appendChild(root);
root.setAttribute("id", object->id().toString());
root.appendChild(idListToXml("parents", object->parents(), doc));
root.appendChild(idListToXml("children", object->children(), doc));
root.appendChild(propertiesToXml(object, doc));
OutFile out(filePath);
doc.save(out(), 2);
}