/** Sets the layout attributes for the detail headers and footers */ void MReportEngine::setDetMiscAttributes( MReportSection * section, QDomNode * report ) { // Get the attributes for the section QDomNamedNodeMap attributes = report->attributes(); // Get the section attributes section->setDrawIf( attributes.namedItem( "DrawIf" ).nodeValue() ); QDomNode levelNode = attributes.namedItem( "Level" ); if ( !levelNode.isNull() ) section->setLevel( attributes.namedItem( "Level" ).nodeValue().toInt() ); else section->setLevel( -1 ); QDomNode n = attributes.namedItem( "NewPage" ); if ( !n.isNull() ) section->setNewPage( n.nodeValue().upper() == "TRUE" ); else section->setNewPage( false ); n = attributes.namedItem( "PlaceAtBottom" ); if ( !n.isNull() ) section->setPlaceAtBottom( n.nodeValue().upper() == "TRUE" ); else section->setPlaceAtBottom( false ); n = attributes.namedItem( "DrawAllPages" ); if ( !n.isNull() ) section->setDrawAllPages( n.nodeValue().upper() == "TRUE" ); else section->setDrawAllPages( false ); }
void WAccount::fillStrings(QString &text, QString &html, const QDomElement &element, const QString &prefix) { QString key = prefix + QLatin1Char('%'); if (key != QLatin1String("%%")) { text.replace(key, element.text()); html.replace(key, element.text().toHtmlEscaped()); qDebug() << key; } key.chop(1); QDomNamedNodeMap attributes = element.attributes(); for (int i = 0; i < attributes.count(); ++i) { QDomNode attribute = attributes.item(i); QString attributeKey = key % QLatin1Char('/') % attribute.nodeName() % QLatin1Char('%'); qDebug() << attributeKey; text.replace(attributeKey, attribute.nodeValue()); html.replace(attributeKey, attribute.nodeValue().toHtmlEscaped()); } if (!key.endsWith(QLatin1Char('%'))) key += QLatin1Char('/'); QDomNodeList elementChildren = element.childNodes(); for (int i = 0; i < elementChildren.count(); ++i) { QDomNode node = elementChildren.at(i); if (node.isElement()) fillStrings(text, html, node.toElement(), key + node.nodeName()); } }
QString Reference::applyString( const QDomElement &context ) const { if( isEmpty() ) return QString(); Reference::Segment s = lastSegment(); QString txt; if ( s.isAttribute() ) { QDomElement targetElement = applyAttributeContext( context ); txt = targetElement.attribute( s.name() ); } else { QDomElement e = applyElement( context ); if( e.isText() ) txt = e.text(); else { QDomNode child = e.firstChild(); if( !child.nodeValue().isEmpty() ) txt = child.nodeValue(); else txt = child.nodeName(); } } return txt; }
//! [3] QVariant DomModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (role != Qt::DisplayRole) return QVariant(); DomItem *item = static_cast<DomItem*>(index.internalPointer()); QDomNode node = item->node(); //! [3] //! [4] QStringList attributes; QDomNamedNodeMap attributeMap = node.attributes(); switch (index.column()) { case 0: return node.nodeName(); case 1: for (int i = 0; i < attributeMap.count(); ++i) { QDomNode attribute = attributeMap.item(i); attributes << attribute.nodeName() + "=\"" +attribute.nodeValue() + "\""; } return attributes.join(" "); case 2: return node.nodeValue().split("\n").join(" "); default: return QVariant(); } }
bool ReturnInstruction::setAsXMLNode(QDomNode& node) { if (node.hasChildNodes()) { QDomNodeList nodeList = node.childNodes(); for (unsigned i = 0; i < nodeList.length(); i++) { QDomElement e = nodeList.item(i).toElement(); if (!e.isNull()) { if (e.tagName() == "text") { QDomNode t = e.firstChild(); setContents(t.nodeValue()); } else if (e.tagName() == "comment") { QDomNode t = e.firstChild(); setComment(t.nodeValue()); } } } } else { // tekst, komentarz i pixmapa puste } validateContents(); return true; }
void GTest_RunCMDLine::setArgs(const QDomElement & el) { QString commandLine; QDomNamedNodeMap map = el.attributes(); int mapSz = map.length(); for( int i = 0; i < mapSz; ++i ) { QDomNode node = map.item(i); if(node.nodeName() == "message"){ expectedMessage = node.nodeValue(); continue; } if(node.nodeName() == "nomessage"){ unexpectedMessage = node.nodeValue(); continue; } if(node.nodeName() == WORKINK_DIR_ATTR){ continue; } QString argument = "--" + node.nodeName() + "=" + getVal(node.nodeValue()); if( argument.startsWith("--task") ) { args.prepend(argument); commandLine.prepend(argument + " "); } else { args.append(argument); commandLine.append(argument + " "); } } args.append("--log-level-details"); args.append("--lang=en"); args.append("--log-no-task-progress"); commandLine.append(QString(" --log-level-details --lang=en --log-no-task-progress")); cmdLog.info(commandLine); }
bool TestBaseLine::isDeepEqual(const QDomNode &n1, const QDomNode &n2) { if(n1.nodeType() != n2.nodeType()) return false; switch(n1.nodeType()) { case QDomNode::CommentNode: /* Fallthrough. */ case QDomNode::TextNode: { return static_cast<const QDomCharacterData &>(n1).data() == static_cast<const QDomCharacterData &>(n2).data(); } case QDomNode::ProcessingInstructionNode: { return n1.nodeName() == n2.nodeName() && n1.nodeValue() == n2.nodeValue(); } case QDomNode::DocumentNode: return isChildrenDeepEqual(n1.childNodes(), n2.childNodes()); case QDomNode::ElementNode: { return n1.localName() == n2.localName() && n1.namespaceURI() == n2.namespaceURI() && n1.nodeName() == n2.nodeName() && /* Yes, this one is needed in addition to localName(). */ isAttributesEqual(n1.attributes(), n2.attributes()) && isChildrenDeepEqual(n1.childNodes(), n2.childNodes()); } /* Fallthrough all these. */ case QDomNode::EntityReferenceNode: case QDomNode::CDATASectionNode: case QDomNode::EntityNode: case QDomNode::DocumentTypeNode: case QDomNode::DocumentFragmentNode: case QDomNode::NotationNode: case QDomNode::BaseNode: case QDomNode::CharacterDataNode: { Q_ASSERT_X(false, Q_FUNC_INFO, "An unsupported node type was encountered."); return false; } case QDomNode::AttributeNode: { Q_ASSERT_X(false, Q_FUNC_INFO, "This should never happen. QDom doesn't allow us to compare DOM attributes " "properly."); return false; } default: { Q_ASSERT_X(false, Q_FUNC_INFO, "Unhandled QDom::NodeType value."); return false; } } }
void TrackerSettingsWidget::deserialize(const QDomNode *node) { mProjectList->clear(); QDomNode itemNode = node->namedItem("login"); if (!itemNode.isNull()) { QDomNode attr = itemNode.attributes().namedItem("value"); if (!attr.isNull()) { mLoginEdit->setText(attr.nodeValue()); } } itemNode = node->namedItem("password"); if (!itemNode.isNull()) { QDomNode attr = itemNode.attributes().namedItem("value"); if (!attr.isNull()) { mPasswordEdit->setText(attr.nodeValue()); } } itemNode = node->namedItem("endpoint"); if (!itemNode.isNull()) { QDomNode attr = itemNode.attributes().namedItem("value"); if (!attr.isNull()) { mUrlEdit->setText(attr.nodeValue()); } } QDomNode projectsRootNode = node->namedItem("projects"); if (!projectsRootNode.isNull()) { QDomNodeList projects = projectsRootNode.childNodes(); for (int i = 0; i < projects.size(); ++i) { QDomNode proj = projects.item(i); QDomNode nameAttr = proj.attributes().namedItem("name"); QString name, shortName; if (!nameAttr.isNull()) { name = nameAttr.nodeValue(); } nameAttr = proj.attributes().namedItem("shortName"); if (!nameAttr.isNull()) shortName = nameAttr.nodeValue(); if (!name.isEmpty() && !shortName.isEmpty()) mProjectList->addItem(name, shortName); } } testConnection(); }
QVariant DomModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); //role to get full xml path of index if(role == XPathRole) { QString wholeXmlPath; DomItem *item = static_cast<DomItem*>(index.internalPointer()); if (item==NULL) qFatal("can't convert domitem from datamodel"); for(;item->parent()!=NULL;item=item->parent()) { wholeXmlPath=item->node().nodeName()+"/"+wholeXmlPath; } wholeXmlPath="/"+wholeXmlPath; return wholeXmlPath; } else if (role == Qt::DisplayRole) { DomItem *item = static_cast<DomItem*>(index.internalPointer()); QDomNode node = item->node(); QStringList attributes; QDomNamedNodeMap attributeMap = node.attributes(); switch (index.column()) { //name case 0: return node.nodeName(); //attributes case 1: for (int i = 0; i < attributeMap.count(); ++i) { QDomNode attribute = attributeMap.item(i); attributes << attribute.nodeName() + "=\"" +attribute.nodeValue() + "\""; } return attributes.join(" "); //value case 2: return node.nodeValue().split("\n").join(" "); default: return QVariant(); } } else return QVariant(); }
void ViElement::fromDom(QDomNode &dom) { setName(dom.toElement().tagName()); QDomNamedNodeMap attributes = dom.attributes(); for(int i = 0; i < attributes.size(); ++i) { addAttribute(ViAttribute(attributes.item(i).nodeName(), attributes.item(i).nodeValue())); } QDomNodeList children = dom.childNodes(); if(children.size() > 0) { for(int i = 0; i < children.size(); ++i) { if(children.item(i).isText()) { setValue(children.item(i).nodeValue()); } else { ViElement child; QDomNode node = children.item(i); child.fromDom(node); addChild(child); } } } else { setValue(dom.nodeValue()); } }
void FileWriter::writeElementChilds(const QDomElement &AParent) { QDomNode node = AParent.firstChild(); while (!node.isNull()) { if (node.isElement()) { QDomElement elem = node.toElement(); if (elem.tagName() != "thread") { FXmlWriter->writeStartElement(elem.tagName()); QString elemNs = elem.namespaceURI(); if (!elemNs.isEmpty() && elem.parentNode().namespaceURI()!=elemNs) FXmlWriter->writeAttribute("xmlns",elem.namespaceURI()); QDomNamedNodeMap attrMap = elem.attributes(); for (uint i=0; i<attrMap.length(); i++) { QDomNode attrNode = attrMap.item(i); FXmlWriter->writeAttribute(attrNode.nodeName(), attrNode.nodeValue()); } writeElementChilds(elem); FXmlWriter->writeEndElement(); } } else if (node.isCharacterData()) { FXmlWriter->writeCharacters(node.toCharacterData().data()); } node = node.nextSibling(); } }
QString QDomNodeProto:: nodeValue() const { QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject()); if (item) return item->nodeValue(); return QString(); }
QString ExampleContent::extractTextFromParagraph(const QDomNode &parentNode) { QString description; QDomNode node = parentNode.firstChild(); while (!node.isNull()) { QString beginTag; QString endTag; if (node.isText()) description += Colors::contentColor + node.nodeValue(); else if (node.hasChildNodes()) { if (node.nodeName() == "b") { beginTag = "<b>"; endTag = "</b>"; } else if (node.nodeName() == "a") { beginTag = Colors::contentColor; endTag = "</font>"; } else if (node.nodeName() == "i") { beginTag = "<i>"; endTag = "</i>"; } else if (node.nodeName() == "tt") { beginTag = "<tt>"; endTag = "</tt>"; } description += beginTag + this->extractTextFromParagraph(node) + endTag; } node = node.nextSibling(); } return description; }
// Add an object to this space from a dom element void GOCXMLSpace::goc_addXMLObject(QDomElement xmlObjectElem){ //Create an XMLObject from the dom element - in this XMLSpace GOCXMLObject *xmlObj = new GOCXMLObject(xmlObjectElem,this); QDomNode nObjNode = xmlObjectElem.firstChild(); if(!nObjNode.isNull() && !nObjNode.isText()){//TODO: manage the text case and comments //Create a sub space of the object - if it has child(ren) xmlObj->goc_setXMLObjectSubbed(true); } GOCXMLSpace *xmlObjSubSpace = xmlObj->goc_getXMLObjectSpace(); while(!nObjNode.isNull()) { QDomElement e = nObjNode.toElement(); // try to convert the node to an element. if(!nObjNode.isText()){ //Add a new object xmlObjSubSpace->goc_addXMLObject(e); }else{ //Update the node value QString sNodeValue = nObjNode.nodeValue(); QVariant vNodeValue = QVariant(sNodeValue); GOCAttribute *gocAtt = new GOCAttribute(xmlObj); QSharedPointer<GOCAttribute> spAtt(gocAtt); spAtt->attName = GOCOBJECT_OBJECTNODEVALUE; spAtt->attValue = vNodeValue; spAtt->attVisible = true; spAtt->attRemovable = false; xmlObj->goc_setObjectNodeValue(sNodeValue); spAtt->attNameModifiable = false; } nObjNode = nObjNode.nextSibling(); } }
/** * \en * Deletes row, having section tag * \_en * \ru * Рекурсивная функция. Удаляет строки, содержащие тег секции * \_ru * \param node - \en context \_en \ru узел из которого нужно удалить строки \_ru */ void aMSOTemplate::clearRow(QDomNode node) { QDomNode n = node.lastChild(); while( !n.isNull() ) { if(n.isText()) { QString str = n.nodeValue(); QRegExp re; re.setPattern(QString("%1.*%2").arg(open_token_section).arg(close_token_section)); re.setMinimal(true); int pos = re.search(str,0); if(pos!=-1) { QDomNode tmp = n; while(!tmp.parentNode().isNull()) { tmp = tmp.parentNode(); if( tmp.nodeName()=="Row" ) { tmp.parentNode().removeChild(tmp); break; } } } } else { clearRow(n); } n = n.previousSibling(); } }
/** * \en * Return true, if node contain tag * \_en * \ru * Возвращает истину, когда текст ноды содержит тег с заданным именем. * \_en * \param node - \en context for searching \_en \ru узел, с которого осуществляется поиск. \_ru * \param sname - \en tag name \_en \ru имя тега для поиска \_ru * \param params - \en true, if find simple tag and false, if section \_en * \ru true, если ищется обычный тег и false, если ищется тег секции \_ru */ bool aMSOTemplate::getNodeTags(QDomNode node, const QString &tagname, bool params ) { if(node.isText()) { QString str = node.nodeValue(); QRegExp re; if(params) { re.setPattern(QString("%1.*%2").arg(open_token).arg(close_token)); } else { re.setPattern(QString("%1.*%2").arg(open_token_section).arg(close_token_section)); } re.setMinimal(true); int pos = re.search(str,0); while(pos != -1) { if(tagname == str.mid(pos+2, re.matchedLength()-4)) { return true; } pos+= re.matchedLength(); pos = re.search(str,pos); } } return false; }
void WbWidget::checkForViewBoxChange(const QDomNode &node) { if(node.isAttr() && node.nodeName().toLower() == "viewbox" && node.parentNode() == session_->document().documentElement()) { QRectF box = parseSvgViewBox(node.nodeValue()); if(box.width() > 0 && box.height() > 0) { scene_->setSceneRect(box); } } }
Factory::Properties Factory::getAttributesFromXML(const QDomNamedNodeMap & m) { Properties result; for (int i = 0; i < m.length(); i++) { QDomNode node = m.item(i); result.insert(node.nodeName(), node.nodeValue()); } return result; }
void TwitterClient::resultReceiver(QString data) { bar.hide(); qDebug() << data; QDomDocument xml; xml.setContent(data); QDomElement rsp = xml.firstChildElement("rsp"); if (rsp.isNull()) { QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Wrong server response.")); emit errorHappened(); return; } QDomElement error = rsp.firstChildElement("err"); if (!error.isNull()) { /* 1002 media not found 2005 media is too big 2001 invalid action specified 2004 invalid developer key 1001 empty/invalid username/password 2002 failed to upload media 2003 failed to update status*/ QDomNode codex = error.attributes().namedItem("code"); if (!codex.isNull()) { QString code = codex.nodeValue(); if (code == "1001") { QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Wrong credentials.")); emit errorHappened(); return; } else if (code == "2003") { QMessageBox::critical(NULL, tr("Error"), tr("Failed to update twitter status.")); emit errorHappened(); return; } } QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Internal error.")); return; } QDomElement statusid = rsp.firstChildElement("statusid"); if (statusid.isNull()) { QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Wrong server response.")); return; } QString addr("http://twitter.com/%1/status/%2"); addr = addr.arg(user, statusid.text()); QDesktopServices().openUrl(QUrl(addr)); }
bool TestBaseLine::isAttributesEqual(const QDomNamedNodeMap &cl1, const QDomNamedNodeMap &cl2) { const unsigned int len = cl1.length(); pDebug() << "LEN:" << len; if(len == cl2.length()) { for(unsigned int i1 = 0; i1 < len; ++i1) { const QDomNode attr1(cl1.item(i1)); Q_ASSERT(!attr1.isNull()); /* This is set if attr1 cannot be found at all in cl2. */ bool earlyExit = false; for(unsigned int i2 = 0; i2 < len; ++i2) { const QDomNode attr2(cl2.item(i2)); Q_ASSERT(!attr2.isNull()); pDebug() << "ATTR1:" << attr1.localName() << attr1.namespaceURI() << attr1.prefix() << attr1.nodeName(); pDebug() << "ATTR2:" << attr2.localName() << attr2.namespaceURI() << attr2.prefix() << attr2.nodeName(); if(attr1.localName() == attr2.localName() && attr1.namespaceURI() == attr2.namespaceURI() && attr1.prefix() == attr2.prefix() && attr1.nodeName() == attr2.nodeName() && /* Yes, needed in addition to all the other. */ attr1.nodeValue() == attr2.nodeValue()) { earlyExit = true; break; } } if(!earlyExit) { /* An attribute was found that doesn't exist in the other list so exit. */ return false; } } return true; } else return false; }
QVariant XUPProjectModel::data( const QModelIndex& index, int role ) const { if ( !index.isValid() ) { return QVariant(); } XUPItem* item = static_cast<XUPItem*>( index.internalPointer() ); switch ( role ) { case Qt::DecorationRole: return item->displayIcon(); case Qt::DisplayRole: return item->displayText(); case XUPProjectModel::TypeRole: return item->type(); case Qt::ToolTipRole: { const QDomNode node = item->node(); const QDomNamedNodeMap attributeMap = node.attributes(); QStringList attributes; if ( item->type() == XUPItem::Project ) { attributes << QString( "Project: %1" ).arg( item->project()->fileName() ); } for ( int i = 0; i < attributeMap.count(); i++ ) { const QDomNode attribute = attributeMap.item( i ); const QString name = attribute.nodeName(); const QString value = attribute.nodeValue(); attributes << QString( "%1=\"%2\"" ).arg( name ).arg( value ); } switch ( item->type() ) { case XUPItem::Value: attributes << QString( "Value=\"%1\"" ).arg( item->content() ); break; case XUPItem::File: attributes << QString( "File=\"%1\"" ).arg( item->content() ); break; case XUPItem::Path: attributes << QString( "Path=\"%1\"" ).arg( item->content() ); break; default: break; } return attributes.join( "\n" ); } case Qt::SizeHintRole: return QSize( -1, 18 ); default: break; } return QVariant(); }
// debugging function that prints the attributes of an element void printAttributes(QDomElement e, uint level) { QDomNamedNodeMap m = e.attributes(); for (uint i=0; i<m.length(); ++i) { for (uint j=0; j<level; ++j) out << ' '; QDomNode n = m.item(i); out << "+"<<n.nodeName() << ": " << n.nodeValue() << endl; } }
/** * \en * Addes to tag value of parametr \a tagName * \_en * \ru * Добавляет к тегу значение параметра \a tagName. После вызова этой функции тег не исчезает, * и к нему можно добавить еще значения, которые добавятся к концу текста, содержащего тег. * \_ru * \param node - \en context \_en \ru узел к которому добавляется значение \_ru * \param sname - \en tag name \_en \ru имя тега \_ru */ void aMSOTemplate::insertTagsValues(QDomNode node, const QString &tagName) { QDomNode n = node; //old vers. //n.setNodeValue(n.nodeValue()+getValue(tagName)); QString s = n.nodeValue(), tag = QString("%1%2%3").arg(open_token).arg(tagName).arg(close_token); s.replace(tag, QString("%1%2").arg(tag).arg(getValue(tagName))); n.setNodeValue(s); }
QString QDomNodeProto::toString() const { QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject()); if (item) return QString("[QDomNode(%1=%2, %3, %4)]") .arg(item->nodeName()) .arg(item->nodeValue()) .arg(item->nodeType()) .arg(item->hasChildNodes() ? "has children" : "leaf node"); return QString("[QDomNode(unknown)]"); }
QString StoreVCard::getElementStore( const QDomDocument *doc, const QString &nodeName ) { QString ret(""); QDomNode nodeElement = doc->elementsByTagName( nodeName ).item(0); QDomNode te = nodeElement.firstChild(); if (!te.isNull()) ret = te.nodeValue(); return ret; }
void UiConverter::fixEnumNode(QDomElement el, QDomDocument *) { QDomNode valueNode = el.firstChild(); if (valueNode.isNull()) { ReportHandler::warning(QString::fromLatin1("Bad enum value at '%1'").arg(el.nodeValue())); return; } QString cppEnumValue = valueNode.nodeValue(); QString javaEnumValue = translateEnumValue(cppEnumValue); valueNode.setNodeValue(javaEnumValue); }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDomDocument (doc); QFile file("my.xml"); if(!file.open(QIODevice::ReadOnly)) { return 0; } QString errorStr; int errorLine; int errorColumnn; if(!doc.setContent(&file,false,&errorStr,&errorLine,&errorColumnn)) { qDebug() << "file closed"; std::cerr << "Error: Parse error at line" << errorLine <<"," << "cloumn" << errorColumnn << ":" << qPrintable(errorStr) << std::endl; file.close(); return 0; } file.close(); QDomNode firstNote = doc.firstChild(); qDebug() << qPrintable(firstNote.nodeName()) <<qPrintable(firstNote.nodeValue()); QDomElement docElem = doc.documentElement(); QDomNode n = docElem.firstChild(); while(!n.isNull()) { if(n.isElement()) { QDomElement e = n.toElement(); qDebug() << qPrintable(e.tagName()) << qPrintable(e.attribute("id")); QDomNodeList list = e.childNodes(); for(int i=0; i<list.count();i++) { QDomNode node = list.at(i); if(node.isElement()) qDebug() << " " << qPrintable(node.toElement().tagName()) << qPrintable(node.toElement().text()); } } n = n.nextSibling(); } return a.exec(); }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // 新建QDomDocument类对象,它代表一个XML文档 QDomDocument doc; QFile file("../myDOM1/my.xml"); if (!file.open(QIODevice::ReadOnly)) return 0; // 将文件内容读到doc中 if (!doc.setContent(&file)) { file.close(); return 0; } // 关闭文件 file.close(); // 获得doc的第一个结点,即XML说明 QDomNode firstNode = doc.firstChild(); // 输出XML说明,nodeName()为“xml”,nodeValue()为版本和编码信息 qDebug() << qPrintable(firstNode.nodeName()) << qPrintable(firstNode.nodeValue()); // 返回根元素 QDomElement docElem = doc.documentElement(); // 返回根节点的第一个子结点 QDomNode n = docElem.firstChild(); // 如果结点不为空,则转到下一个节点 while(!n.isNull()) { // 如果结点是元素 if (n.isElement()) { // 将其转换为元素 QDomElement e = n.toElement(); // 返回元素标记和id属性的值 qDebug() << qPrintable(e.tagName()) << qPrintable(e.attribute("id")); // 获得元素e的所有子结点的列表 QDomNodeList list = e.childNodes(); // 遍历该列表 for(int i=0; i<list.count(); i++) { QDomNode node = list.at(i); if(node.isElement()) qDebug() << " "<< qPrintable(node.toElement().tagName()) <<qPrintable(node.toElement().text()); } } // 转到下一个兄弟结点 n = n.nextSibling(); } return a.exec(); }
void Configure::printTree(QDomElement element,QString indent) { QDomNode n = element.firstChild(); if(n.isText()) { qDebug()<<element.tagName()<<":"<<n.nodeValue(); widget.textEditConfiguration->append(indent+element.tagName()+": "+n.nodeValue()); // save interesting information if(element.tagName()=="type") { serverType=n.nodeValue(); } else if(element.tagName()=="samplerate") { sampleRate=n.nodeValue().toInt(); } else if(element.tagName()=="minfrequency") { minFrequency=n.nodeValue().toLong(); } else if(element.tagName()=="maxfrequency") { maxFrequency=n.nodeValue().toLong(); } } else { qDebug()<<element.tagName(); widget.textEditConfiguration->append(indent+element.tagName()); while(!n.isNull()) { QDomElement e = n.toElement(); // try to convert the node to an element. if(!e.isNull()) { if(e.hasAttributes()) { QDomNamedNodeMap attributes=e.attributes(); qDebug()<<"attributes:"<<attributes.count(); for(int i=0;i<attributes.count();i++) { QDomNode a=attributes.item(i); qDebug()<<"attribute: "<<a.nodeName()<<":"<<a.nodeValue(); } } printTree(e,indent+" "); } n = n.nextSibling(); } } }
void SvgView::updateField(QDomNode &e, QString tag, QString value) { if ( e.nodeType() == QDomNode::TextNode) { if (e.nodeValue() == tag) e.setNodeValue(value); } else { for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) updateField(n, tag, value); } }