我正在尝试阅读和xml文件并使用以下代码解析它可以有人建议我犯了什么错误。
显示错误
错误:(E549)未捕获异常:ConfigException:expected<
void ParserCnfFile::read(void) {
ifstream file(m_file.m_name.c_str(), ios::in | ios::binary | ios::ate);
if (file.is_open()) {
file.seekg(0, ios::end);
int size = file.tellg();
m_file.m_contents = new char[size];
file.seekg(0, ios::beg);
file.read(m_file.m_contents, size);
file.close();
} else {
throw ConfigException("ConfigExpection: Could not open \"" +
m_file.m_name + "\"");
}
}
void ParserCnfFile::parse(void) {
xml_document<> doc; // character type defaults to char
try {
doc.parse<0>(m_file.m_contents);
flags
} catch (rapidxml::parse_error& e) {
cout << m_file.m_contents << endl;
throw ConfigException(string() + "ConfigExpection: " + e.what());
}
xml_node<>* rootNode = doc.first_node();
xml_node<>* node = rootNode->first_node();
}
这是我的xml文件。
<?xml version="1.0"?>
<GlobalSettings>
<Simulation>
<TimeResolution unit="ns"> 100 </TimeResolution>
<Duration unit="s"> 600 </Duration>
</Simulation>
</GlobalSettings>