int LibraryDetectionManager::LoadXmlConfig(const wxString& Path) { wxDir Dir(Path); wxString Name; if ( !Dir.IsOpened() ) return 0; int loaded = 0; if ( Dir.GetFirst(&Name,wxEmptyString,wxDIR_DIRS|wxDIR_HIDDEN) ) { do { loaded += LoadXmlConfig(Path+wxFileName::GetPathSeparator()+Name); } while ( Dir.GetNext(&Name) ); } if ( Dir.GetFirst(&Name,wxEmptyString,wxDIR_FILES|wxDIR_HIDDEN) ) { do { loaded += LoadXmlFile(Path+wxFileName::GetPathSeparator()+Name) ? 1 : 0; } while ( Dir.GetNext(&Name) ); } return loaded; }
bool XmlHelper::ParseXmlDocument(const QString &file_name) { file_name_ = file_name; if (!LoadXmlFile()) { return false; } QDomElement doc_elem = doc_.documentElement(); QDomNode node = doc_elem.firstChild(); while (!node.isNull()) { QDomElement elem = node.toElement(); if (!elem.isNull()) { qDebug() << elem.tagName() << ": " << elem.text() << endl; } node = node.nextSibling(); } doc_.clear(); return true; }
bool XmlHelper::SetXmlNodeAttribute(const QString& node_tag, const QString &attr_key, const QString &attr_value) { if (!LoadXmlFile()) { return false; } QDomNodeList node_list = doc_.elementsByTagName(node_tag); if (node_list.count() > 0) { QDomElement elem = node_list.at(0).toElement(); elem.setAttribute(attr_key, attr_value); QFile file(file_name_); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { return false; } QTextStream out(&file); doc_.save(out, 4); file.close(); return true; } return false; }
bool XmlHelper::RemoveXmlNode(const QString &node_tag) { if (!LoadXmlFile()) { return false; } QDomNodeList node_list = doc_.elementsByTagName(node_tag); if (node_list.count() > 0) { QDomNode parent(node_list.at(0).parentNode()); parent.removeChild(node_list.at(0)); QFile file(file_name_); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { return false; } QTextStream out(&file); doc_.save(out, 4); file.close(); return true; } return false; }
bool XmlHelper::AddXmlNode(const QString &parent_tag, const QString &node_tag, const QString &text) { if (!LoadXmlFile()) { return false; } QDomNodeList node_list = doc_.elementsByTagName(parent_tag); if (node_list.count() > 0) { QDomElement elem = doc_.createElement(node_tag); QDomText elem_text = doc_.createTextNode(text); elem.appendChild(elem_text); node_list.at(0).appendChild(elem); QFile file(file_name_); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { return false; } QTextStream out(&file); doc_.save(out, 4); file.close(); return true; } return false; }
QDomElement XmlHelper::GetXmlRootNode() { if (!LoadXmlFile()) { return QDomElement(); } return doc_.firstChild().toElement(); }
void CGmxmlFailure :: ConstructL() { iSession.Connect(); iCMDXMLParser = CMDXMLParser::NewL(this); log->AppendComment(_L8("Performing tests on opening non-existing file")); LoadXmlFile(KNonExistingFilePath); log->AppendComment(_L8("Completed checking of opening non-existing file")); CActiveScheduler::Add(this); iState = ENonExistFileState; TRequestStatus *s = &iStatus; User::RequestComplete(s, KErrNone); SetActive(); }
QDomElement XmlHelper::GetXmlNodeParent(const QString &node_tag) { if (!LoadXmlFile()) { return QDomElement(); } QDomNodeList node_list = doc_.elementsByTagName(node_tag); if (node_list.count() > 0) { return node_list.at(0).toElement(); } return QDomElement(); }
QString XmlHelper::ParseXmlNodeAttribute(const QDomElement &elem, const QString& attr_key) { if (!LoadXmlFile()) { return QString(); } QString str; QDomNodeList node_list = doc_.elementsByTagName(elem.tagName()); if (node_list.count() > 0) { QDomElement elem = node_list.at(0).toElement(); str = elem.attributeNode(attr_key).toText().data(); } return str; }
QStringList XmlHelper::ParseXmlNodeList(const QString &node_tag) { QStringList str_list; if (!LoadXmlFile()) { return str_list; } QDomNodeList node_list = doc_.elementsByTagName(node_tag); for (int i = 0; i < node_list.count(); i++) { if (!node_list.at(i).firstChild().isText()) { str_list.append(node_list.at(i).toElement().text()); } } return str_list; }
QString XmlHelper::ParseXmlNodeContent(const QString &node_tag) { if (!LoadXmlFile()) { return QString(); } QDomNodeList node_list = doc_.elementsByTagName(node_tag); if (node_list.count() > 0) { if (!node_list.at(0).firstChild().isText()) { return QString(); } return node_list.at(0).toElement().text(); } return QString(); }
QString XmlHelper::ParseXmlNodeContent(const QDomNode &special_node) { if (!LoadXmlFile()) { return QString(); } QDomElement root = doc_.documentElement(); QDomNode node = root.firstChild(); while (!node.isNull()) { if (node.toElement().tagName() == special_node.toElement().tagName()) { return special_node.toElement().text(); } node = node.nextSibling(); } return QString(""); }
bool XmlHelper::SetXmlNodeContent(const QString &tag_name, const QString &text) { if (!LoadXmlFile()) { return false; } QDomElement root = doc_.documentElement(); QDomNodeList node_list = root.elementsByTagName(tag_name); if (node_list.count() > 0) { QDomElement elems = node_list.at(0).toElement(); QDomNode old_node = elems.firstChild(); if (elems.firstChild().isText()) { elems.firstChild().setNodeValue(text); QDomNode new_node = elems.firstChild(); elems.replaceChild(new_node, old_node); } else { elems.firstChild().setNodeValue(text); QDomText text_node; text_node.setNodeValue(text); QDomNode new_node = elems.firstChild(); new_node.appendChild(text_node); elems.replaceChild(new_node, old_node); } QFile file(file_name_); if (!file.open(QIODevice::WriteOnly)) { return false; } QTextStream out(&file); doc_.save(out, 4); file.close(); return true; } return false; }
bool XmlHelper::SetXmlNodeContent(const QDomElement &elem, const QString&) { if (!LoadXmlFile()) { return false; } QDomElement root = doc_.documentElement(); QDomNode node = root.firstChild(); while (!node.isNull()) { if (node.toElement().tagName() == elem.tagName()) { doc_.replaceChild(elem, node); return true; } node = node.nextSibling(); } return false; }
CConfig::CConfig() { //LoadConfigFile(); LoadXmlFile(); }
void CSolarSystemDoc::LoadFile(const CString& fileName) { m_SolarSystem.clear(); LoadXmlFile(fileName); }