【问题标题】:Recursive pugixml, can't get values递归pugixml,无法获取值
【发布时间】:2013-07-19 03:09:40
【问题描述】:

好吧,我得到了代码

pugi::xml_node text = doc.child("text").child("girl");

for (int i = 0; i < situations.size(); i++)
{
    std::cout << situations[i] << std::endl;
    text = text.child(situations[i].c_str()); // problem
}

在那段代码之后,我无法从文本中获取任何值,但可以直接使用 like

doc.child("text").child("girl").child_value("day1")

正在工作。 需要帮忙。 谢谢。

【问题讨论】:

  • 那是什么情况?它包含什么?您是否尝试过使用 doc.child(situations[i].c_str())?

标签: c++ xml parsing pugixml


【解决方案1】:

您应该使用 text.child_value() 或 text.text().get() 而不是 text.value()。

child_value("a") 等价于 child("a").child_value(),而不是 child("a").value()。原因是文本位于特殊的 PCDATA 节点中 - child_value() 通常与 first_child().value() 相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-23
    • 1970-01-01
    • 2014-04-10
    • 2023-01-11
    • 2021-10-23
    • 2022-01-20
    • 2015-07-16
    • 1970-01-01
    相关资源
    最近更新 更多