0

如何让 pugi XML 找到具有相对路径的文件。

我的文件夹看起来像这样

XML 文件位于此处

XMLConfiguration->_master_config.xml

配置->src

我把代码放在这里

pugi::xml_document doc;

pugi::xml_parse_result result = doc.load_file("../../XMLConfiguration/_master_config.xml");

std::cout << "Load result: " << result.description() << ", mesh name: "      << doc.child("mesh").attribute("name").value() << std::endl; 

当我运行代码时,我得到了这个:

Load result: File was not found, mesh name: 
4

2 回答 2

0

您可以随时尝试:

pugi::xml_document doc;

std::ifstream ifs("../../XMLConfiguration/_master_config.xml");

pugi::xml_parse_result result = doc.load(ifs);

编辑:

(尽管在我的测试中你的方法工作正常)。

于 2015-05-07T08:27:46.023 回答
0

错误是我没有将文件复制到构建文件夹。这样做之后,上面的代码就起作用了。

于 2015-05-07T10:55:55.423 回答