当前位置: 首页>>代码示例>>C++>>正文


C++ XMLElement::DeleteChild方法代码示例

本文整理汇总了C++中XMLElement::DeleteChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::DeleteChild方法的具体用法?C++ XMLElement::DeleteChild怎么用?C++ XMLElement::DeleteChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLElement的用法示例。


在下文中一共展示了XMLElement::DeleteChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

int Configure::load(const string& xmlpath)
{
    if (m_doc.LoadFile(xmlpath.c_str()) != XML_NO_ERROR) {
        g_sysLog.e("{Configure} can't load xml %s\n", xmlpath.c_str());
        return ERR_LDCFG;
    }

    XMLElement* rootElement = m_doc.RootElement();
    if (rootElement == NULL) {
        g_sysLog.e("{Configure} can't get root element %s\n", xmlpath.c_str());
        return ERR_LDCFG;    
    } else {
        bool reset = rootElement->IntAttribute("reset");
        if (reset)
            return ERR_LDCFG;

        int ver = rootElement->IntAttribute("version");
        if (ver != CONF_VERSION)
            return ERR_LDCFG; // Recreate configure.xml
    }

    XMLElement* tempElement = rootElement->FirstChildElement("srclan");
    if (tempElement && tempElement->GetText()) {
        m_srcLan = tempElement->GetText();
    }

    tempElement = rootElement->FirstChildElement("detlan");
    if (tempElement && tempElement->GetText()) {
        m_detLan = tempElement->GetText();
    }

    // Loading dictionary 
    vector<string> dictFiles;
    scanDictDir(dictFiles);

    XMLElement* dictsElement = rootElement->FirstChildElement("dict");
    XMLElement* dictElement = dictsElement->FirstChildElement();
    while (dictElement) {
        struct DictNode dict;
        const char* textE;
        int pos;

        if (dictElement->FirstChildElement("path")) {
            if ((textE = dictElement->FirstChildElement("path")->GetText()) != NULL)
                dict.path = textE;
        }

        if ((pos = findDict(dict.path, dictFiles)) == -1 ) {
            dictsElement->DeleteChild(dictElement);
            dictElement = dictElement->NextSiblingElement();
            continue;
        }
        dictFiles[pos] = "";

        dict.en = dictElement->BoolAttribute("en");
        if (dictElement->Attribute("open"))
            dict.open   = string(dictElement->Attribute("open"));

        if (dictElement->FirstChildElement("srclan")) {
            if ((textE = dictElement->FirstChildElement("srclan")->GetText()) != NULL)
                dict.srclan = textE;
        }
        if (dictElement->FirstChildElement("detlan")) {
	    if ((textE = dictElement->FirstChildElement("detlan")->GetText()) != NULL)
                dict.detlan = textE;
        }

        if (dictElement->FirstChildElement("name")) {
            if ((textE = dictElement->FirstChildElement("name")->GetText()) != NULL)
                dict.name = textE;
        }

        if (dictElement->FirstChildElement("summary")) {
            if ((textE = dictElement->FirstChildElement("summary")->GetText()) != NULL)
	        dict.summary = textE;
        }
        m_dictNodes.push_back(dict);
        dictElement = dictElement->NextSiblingElement();
    }

    vector<string>::iterator iter = dictFiles.begin();
    for (; iter != dictFiles.end(); iter++) {
        if (*iter != "") {
            struct DictNode d;
            d.en = true;
            d.path = *iter;
            d.name = boost::filesystem::path(d.path).filename().string();
            //printf("%s\n",d.name.c_str());
            m_dictNodes.push_back(d);
        }
    }
    // Loading dictionary -- end

    tempElement = rootElement->FirstChildElement(XML_TAG_CWS);
    if (tempElement) {
        m_cws.bselection  = tempElement->BoolAttribute("selection");
        m_cws.bclipboard  = tempElement->BoolAttribute("clipboard");
        m_cws.bmouse      = tempElement->BoolAttribute("mouse");
        m_cws.benable     = tempElement->BoolAttribute("enable"); 
        m_cws.shortcutKey = tempElement->IntAttribute("shortcutkey");
//.........这里部分代码省略.........
开发者ID:kartorz,项目名称:AlphaDict,代码行数:101,代码来源:Configure.cpp


注:本文中的XMLElement::DeleteChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。