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


C++ xml_node::select_node方法代码示例

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


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

示例1: updateListByDataAccessor

void VR_DataProcessor::updateListByDataAccessor(const pugi::xml_node& dataAccessor_result)
{
    VR_LOGD_FUNC();
    pugi::xml_node listNode = dataAccessor_result.select_node("//list").node();
    std::string listId = listNode.attribute("id").as_string();
    std::string xpathStr = "//list[@id='" + listId + "']";
    pugi::xml_node oldListNode = _listData.select_node(xpathStr.c_str()).node();
    if (NULL != oldListNode) {
        _listData.remove_child(oldListNode);
    }
    _listData.append_copy(listNode);
    return;
}
开发者ID:IMF0206,项目名称:GitHubTest,代码行数:13,代码来源:VR_DataProcessor.cpp

示例2: addItemsToDispaly

void VR_DataProcessor::addItemsToDispaly(pugi::xml_node& hintsOrSelectListsNodeScxml)
{
    VR_LOGD_FUNC();
    // get the params (hints) and get some data into _listDataForUI
    std::string listIdScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().attribute("id").as_string();
    std::string pageSizeStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("pageSize").child_value();
    int pageSizeScxml = atoi(pageSizeStrScxml.c_str());
    std::string startIndexStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("startIndex").child_value();
    int startIndexScxml = atoi(startIndexStrScxml.c_str());
    std::string xpathStr = "/list[@id='" + listIdScxml + "']/items/item";
    pugi::xpath_node_set itemXpathNodes = _listData.select_nodes(xpathStr.c_str());
    int count = itemXpathNodes.size();
    VR_LOGD("pageSize = %d, startIndex = %d, all count = %d", pageSizeScxml, startIndexScxml, count);
    if (count < 1) {
        VR_ERROR("when receive the paper operaction of display,can't find listid=%s in DE\n", listIdScxml.c_str());
    }
    else {
        pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node(); 
        // pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.child("list");
        listNodeScxml.remove_child("items");
        pugi::xml_node itemsNodeScxml = listNodeScxml.append_child("items");
        for (int i = 0; i < pageSizeScxml; ++i) {
            int index = startIndexScxml + i;
            if (index < itemXpathNodes.size()) {
                pugi::xml_node nodeIt = itemXpathNodes[index].node();
                itemsNodeScxml.append_copy(nodeIt);
            }
            else {
                VR_LOG("pagesize=%d", pageSizeScxml);
                VR_LOG("startIndex=%d", startIndexScxml);
                VR_LOG("when add items to dispaly list, item has reached end!");
                break;
            }
        }
    }
}
开发者ID:IMF0206,项目名称:GitHubTest,代码行数:36,代码来源:VR_DataProcessor.cpp

示例3: updateListByActionResult

void VR_DataProcessor::updateListByActionResult(pugi::xml_node& action_result)
{
    VR_LOGD_FUNC();
    pugi::xml_node listNode = action_result.select_node("//list").node();
    // save the node in DE
    std::string listId = std::string("list_") + action_result.attribute("op").as_string(); // listNode.attribute("id").as_string();
    listNode.remove_attribute("id");
    listNode.append_attribute("id").set_value(listId.c_str());
    std::string xpathStr = "//list[@id='" + listId + "']";
    pugi::xml_node oldListNode = _listData.select_node(xpathStr.c_str()).node();
    if (NULL != oldListNode) {
        _listData.remove_child(oldListNode);
    }
    _listData.append_copy(listNode);
    return;
}
开发者ID:IMF0206,项目名称:GitHubTest,代码行数:16,代码来源:VR_DataProcessor.cpp

示例4: addItemsToHintsDispaly

void VR_DataProcessor::addItemsToHintsDispaly(pugi::xml_node& hintsOrSelectListsNodeScxml, bool isNavi, bool isInfo)
{
    VR_LOGD_FUNC();
    // get the params (hints) and get some data into _listDataForUI
    std::string listIdScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().attribute("id").as_string();
    std::string pageSizeStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("pageSize").child_value();
    int pageSizeScxml = atoi(pageSizeStrScxml.c_str());
    std::string startIndexStrScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node().child("header").child("startIndex").child_value();
    int startIndexScxml = atoi(startIndexStrScxml.c_str());
    std::string xpathStr = "/list[@id='" + listIdScxml + "']/items/item";
    pugi::xpath_node_set allNodes = _listData.select_nodes(xpathStr.c_str());

    // remove info and navi
    pugi::xml_document docRet;
    pugi::xpath_node_set::iterator it = allNodes.begin();
    while (it != allNodes.end()) {
        docRet.append_copy(it->node());
        ++it;
    }
    if (!isInfo) {
        // remove show="information"
        pugi::xpath_node_set infoNodeSet = docRet.select_nodes("//item[@show='information']");
        pugi::xpath_node_set::iterator it = infoNodeSet.begin();
        if (it != infoNodeSet.end()) {
            docRet.remove_child(it->node());
        }
    }

    if (!isNavi) {
        // remove show="navi"
        pugi::xpath_node_set naviNodeSet = docRet.select_nodes("//item[@show='navi']");
        pugi::xpath_node_set::iterator it = naviNodeSet.begin();
        if (it != naviNodeSet.end()) {
            docRet.remove_child(it->node());
        }
    }
    pugi::xpath_node_set itemXpathNodes = docRet.select_nodes("//item");
    // end

    int count = itemXpathNodes.size();
    VR_LOG("pageSize = %d, startIndex = %d, all count = %d", pageSizeScxml, startIndexScxml, count);
    if (count < 1) {
        VR_ERROR("when receive the paper operaction of display,can't find listid=%s in DE\n", listIdScxml.c_str());
    }
    else {
        pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.select_node("//list[@id]").node();
        // pugi::xml_node listNodeScxml = hintsOrSelectListsNodeScxml.child("list");
        listNodeScxml.remove_child("items");
        pugi::xml_node itemsNodeScxml = listNodeScxml.append_child("items");
        for (int i = 0; i < pageSizeScxml; ++i) {
            int index = startIndexScxml + i;
            if (index < itemXpathNodes.size()) {
                pugi::xml_node nodeIt = itemXpathNodes[index].node();
                itemsNodeScxml.append_copy(nodeIt);
            }
            else {
                VR_LOG("pagesize=%d", pageSizeScxml);
                VR_LOG("startIndex=%d", startIndexScxml);
                VR_LOG("when add items to dispaly list, item has reached end!");
                break;
            }
        }
    }
}
开发者ID:IMF0206,项目名称:GitHubTest,代码行数:64,代码来源:VR_DataProcessor.cpp


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