Reputation: 17
I am trying to read and xml file and parsing it using the below code can somebody suggest what mistake I am making.
It shows the error
Error: (E549) uncaught exception: 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();
}
This is my xml file.
<?xml version="1.0"?>
<GlobalSettings>
<Simulation>
<TimeResolution unit="ns"> 100 </TimeResolution>
<Duration unit="s"> 600 </Duration>
</Simulation>
</GlobalSettings>
Upvotes: 0
Views: 398