本文整理汇总了C++中QDomDocument::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::clear方法的具体用法?C++ QDomDocument::clear怎么用?C++ QDomDocument::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieveFile
/**
* reads an xml file from a specific location given by fileName
* before reading from the output node QDomDocument::isNull() method value
* should be checked. if it returns true then there is an error in reading file
*/
QDomDocument XMLWriter::retrieveFile(QString fileName)
{
QDomDocument domDoc;
bool rdSuccess = true;
QString errorMsg;
int errorLine = 0;
int errorColumn = 0;
// read form file
QFile file(fileName);
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
rdSuccess = domDoc.setContent(&file, &errorMsg, &errorLine, &errorColumn);
file.close();
}else{
qDebug()<< "Couldn't read from file " + file.fileName();
domDoc.clear();
}
if(!rdSuccess){
qWarning() << "XML Read Error: " << errorMsg;
qWarning() << "@line " << errorLine << "| @column " << errorColumn;
domDoc.clear();
}
return domDoc;
}
示例2: main
int Creature::main(int argc, char** argv) {
(void) argc;
(void) argv;
BasicCreature creature(1);
QDomDocument doc;
creature.toXml(doc);
QString xml = doc.toString();
// std::cout << xml.toStdString() << std::endl;
BDEBUG(xml.toStdString());
doc.clear();
QString * error_msg = new QString();
int* error_line = new int();
int* error_col = new int();
doc.setContent(xml, error_msg, error_line, error_col);
std::cout << "Error: " << error_msg->toStdString() << " at [" << *error_line << " , "
<< *error_col << "]" << std::endl;
delete error_msg;
delete error_line;
delete error_col;
QDomElement root = doc.firstChild().toElement();
// creature.fromXml(root);
doc.clear();
creature.toXml(doc);
xml = doc.toString();
BDEBUG("******************************");
BDEBUG(xml.toStdString());
std::cout << xml.toStdString() << std::endl;
return 0;
}
示例3: ecrire
void Dom::ecrire(QString fileName)
{
QFile file;
QDomDocument doc;
QDomElement sauvegarde;
QDomElement racine;
QTextStream out;
doc.clear();
racine=doc.createElement("sauvegardes");
doc.appendChild(racine); // filiation de la balise "sauvegarde"
file.setFileName(fileName);
if (!file.open(QIODevice::WriteOnly)) // ouverture du fichier de sauvegarde
return; // en écriture
out.setDevice(&file); // association du flux au fichier
for(int i=0; i<p.size(); i++){
sauvegarde=doc.createElement("sauvegarde");
sauvegarde.setAttribute("valeur", p.at(i)->toQString());
racine.appendChild(sauvegarde);
}
QDomNode noeud = doc.createProcessingInstruction("xml","version=\"1.0\"");
doc.insertBefore(noeud,doc.firstChild());
// sauvegarde dans le flux (deux espaces de décalage dans l'arborescence)
doc.save(out,2);
file.close();
}
示例4: saveState
void saveState( QDomDocument &stateDoc ) const override
{
stateDoc.clear();
QDomElement documentElement = stateDoc.createElement( QStringLiteral( "UndoState" ) );
mLayout->writeXmlLayoutSettings( documentElement, stateDoc, QgsReadWriteContext() );
stateDoc.appendChild( documentElement );
}
示例5: serialiseXml
//------------------------------------------------------------------------------
//
QString QEMenuButtonModel::serialiseXml () const
{
QDomDocument doc;
QDomElement docElem;
doc.clear ();
docElem = doc.createElement (mainTagName);
docElem.setAttribute (versionAttrName, 1);
doc.appendChild (docElem);
// The core element is not serilaised, it is a model artefact.
// This code snippet (~ 8 lines) mirrors QEMenuButtonItem::createDomElement.
//
const int n = this->coreItem->childCount ();
for (int j = 0; j < n; j++) {
QEMenuButtonItem* child = this->coreItem->getChild (j);
if (child) {
QDomElement childElement = child->createDomElement (doc); // recursive
docElem.appendChild (childElement);
}
}
// Remove newlines - designer's property manager does not handle properties
// with many many lines very well.
//
return doc.toString ().replace ("\n", "");
}
示例6: saveState
void QgsComposerMultiFrameCommand::saveState( QDomDocument& stateDoc )
{
if ( mMultiFrame )
{
stateDoc.clear();
QDomElement documentElement = stateDoc.createElement( "ComposerMultiFrameState" );
mMultiFrame->writeXML( documentElement, stateDoc );
stateDoc.appendChild( documentElement );
}
}
示例7: saveState
void QgsComposerItemCommand::saveState( QDomDocument& stateDoc ) const
{
if ( mItem )
{
stateDoc.clear();
QDomElement documentElement = stateDoc.createElement( "ComposerItemState" );
mItem->writeXML( documentElement, stateDoc );
stateDoc.appendChild( documentElement );
}
}
示例8: expressionToOGCFilter
bool QgsWFSUtils::expressionToOGCFilter( QgsExpression& exp, QDomDocument& doc )
{
doc.clear();
QDomElement filterElem = doc.createElement( "Filter" );
doc.appendChild( filterElem );
QgsExpressionOGCVisitor v( doc, filterElem );
exp.acceptVisitor( v );
return v.result();
}
示例9: saveState
void QgsLayoutItemUndoCommand::saveState( QDomDocument &stateDoc ) const
{
stateDoc.clear();
QDomElement documentElement = stateDoc.createElement( QStringLiteral( "ItemState" ) );
QgsLayoutItem *item = mLayout->itemByUuid( mItemUuid );
Q_ASSERT_X( item, "QgsLayoutItemUndoCommand::saveState", "could not retrieve item for saving state" );
item->writeXml( documentElement, stateDoc, QgsReadWriteContext() );
stateDoc.appendChild( documentElement );
}
示例10: expressionToOGCFilter
bool QgsWFSUtils::expressionToOGCFilter( QgsExpression& exp, QDomDocument& doc )
{
doc.clear();
QDomElement filterElem = doc.createElement( "Filter" );
filterElem.setAttribute( "xmlns:ogc", "http://www.opengis.net/ogc" );
doc.appendChild( filterElem );
QgsExpressionOGCVisitor v( doc, filterElem );
exp.acceptVisitor( v );
return v.result();
}
示例11: saveState
void QgsComposerItemCommand::saveState( QDomDocument& stateDoc ) const
{
const QgsComposerItem* source = item();
if ( !source )
{
return;
}
stateDoc.clear();
QDomElement documentElement = stateDoc.createElement( "ComposerItemState" );
source->writeXML( documentElement, stateDoc );
stateDoc.appendChild( documentElement );
}
示例12: emptyDoc
void
UAList::Domify (QDomDocument & doc)
{
doc.clear ();
QString emptyDoc ("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
emptyDoc.append ("\n");
emptyDoc.append ("<" + UA_FF::tag_File + " version=\"1.0\">\n");
emptyDoc.append ("</" + UA_FF::tag_File + ">\n");
doc.setContent (emptyDoc);
QDomElement root = doc.documentElement ();
AgentMapType::iterator it;
for (it = agents.begin(); it != agents.end(); it++) {
it->second->Domify (doc,root);
}
}
示例13: getToday
QStringList QWeather::getToday()
{
QDomDocument doc;
doc.setContent(xmldoc);
parcer(doc);
doc.clear();
qDebug() << "today" << today_code;
QList<QString> today;
today.append(today_code);
today.append(country);
today.append(region);
today.append(city);
today.append(temperature);
today.append(cf);
today.append(condition);
today.append(today_code);
today.append(chill);
today.append(humidity);
today.append(pressure);
return today;
}
示例14: clear
void QDomDocumentProto::clear()
{
QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
if (item)
item->clear();
}
示例15: openFile
// if no file is open
void MainWindow::openFile(QString &xmlFileName, QFile &xmlFile, QDomDocument &xmlDomDocument, QDomDocument &xmlDomDocumentOrg, bool createFile)
{
QString filename;
// open file diaglog
if(createFile == OPEN_EXISTING_FILE){
// Open diaglog to -- open existing file
filename = QFileDialog::getOpenFileName(this, tr("Open File"),
"",
tr("Files (*.xml)"));
}
else{
// Open diaglog to -- create new file
filename = QFileDialog::getSaveFileName(this, tr("Save File"),
"",
tr("Files (*.xml)"));
}
// Check if cancel button is pressed in the QFileDialog
if(filename != "")
{
//copy file name to globalobject
xmlFileName = filename;
// create new xml file & text stream
//xmlOpenFile();
// Add a delay
xmlLibObject.xmlOpenFile( xmlFileName, xmlFile, xmlStream);
if(createFile == OPEN_EXISTING_FILE){
//Load the XML file
//xmlLoadFile();
xmlLibObject.xmlLoadFile(xmlDomDocument, xmlFile);
//close file
//xmlCloseFile();
//xmlLibObject.xmlCloseFile(xmlStream, xmlDomDocument, xmlFile);
//Now again open & truncate the file
//xmlOpenFileTruncate();
//xmlLibObject.xmlOpenFileTruncate( xmlFileName, xmlFile, xmlStream);
//Get the root element
//xmlGetRoot();
xmlLibObject.xmlGetRoot(xmlRoot, xmlDomDocument);
// copy data to the tree view
// copy data to the text view
loadXmltoTreeAndTextView();
//Its not new file
b_newFileCreationSignal = FALSE;
//create backup for original xml.
xmlDomDocumentOrg.clear();
xmlDomDocumentOrg = xmlDomDocument.cloneNode(true).toDocument();
}
else{
//Add root node
//xmlAddRoot();
xmlLibObject.xmlAddRoot(xmlRoot, xmlDomDocument);
// File contains new node
b_fileDoesNotContainsNode = TRUE;
//New file creation signal
b_newFileCreationSignal = TRUE;
//New file created
xmlDomDocumentOrg.clear();
}
// xml file is already open
b_xmlFileAlreadyOpen = TRUE;
}
else {
// Do nothing cancel presses
}
}