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


C++ xml_document::get_child方法代码示例

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


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

示例1: read_properties_core

void workbook_serializer::read_properties_core(const xml_document &xml)
{
    auto &props = workbook_.get_properties();
    auto root_node = xml.get_child("cp:coreProperties");

    props.excel_base_date = calendar::windows_1900;

    if (root_node.has_child("dc:creator"))
    {
        props.creator = root_node.get_child("dc:creator").get_text();
    }
    if (root_node.has_child("cp:lastModifiedBy"))
    {
        props.last_modified_by = root_node.get_child("cp:lastModifiedBy").get_text();
    }
    if (root_node.has_child("dcterms:created"))
    {
        std::string created_string = root_node.get_child("dcterms:created").get_text();
        props.created = w3cdtf_to_datetime(created_string);
    }
    if (root_node.has_child("dcterms:modified"))
    {
        std::string modified_string = root_node.get_child("dcterms:modified").get_text();
        props.modified = w3cdtf_to_datetime(modified_string);
    }
}
开发者ID:lyntel,项目名称:xlnt,代码行数:26,代码来源:workbook_serializer.cpp

示例2: read_shared_strings

bool shared_strings_serializer::read_shared_strings(const xml_document &xml, std::vector<std::string> &strings)
{
    strings.clear();

    auto root_node = xml.get_child("sst");
    auto unique_count = 0;

    if (root_node.has_attribute("uniqueCount"))
    {
        unique_count = std::stoull(root_node.get_attribute("uniqueCount"));
    }

    for (const auto &si_node : root_node.get_children())
    {
        if (si_node.get_name() != "si")
        {
            continue;
        }

        if (si_node.has_child("t"))
        {
            strings.push_back(si_node.get_child("t").get_text());
        }
        else if (si_node.has_child("r"))
        {
            strings.push_back(si_node.get_child("r").get_child("t").get_text());
        }
    }

    if (unique_count != strings.size())
    {
        throw std::runtime_error("counts don't match");
    }

    return true;
}
开发者ID:lyntel,项目名称:xlnt,代码行数:36,代码来源:shared_strings_serializer.cpp


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