usingnamespace rapidxml;
std::string input_xml;
std::string line;
std::ifstream in("testtable.xml");
// read file into input_xml
while(getline(in,line)){
std::cout << line << std::endl;
input_xml += line;
}
// Run the RapidXML parser inputting the string that has just been loaded.
std::vector<char> xml_copy(input_xml.begin(), input_xml.end());
xml_copy.push_back('\0');
xml_document<> doc;
doc.parse<parse_full>(&xml_copy[0]); // Wrong flags here?
xml_node<> *node = doc.first_node(0);
while (node != 0){
std::cout << "Name of node is: " << *node->name()<< "\n"; // <-- Wrong output here.
node = &(*node->next_sibling()); // Assign a reference of *node's next sibling to the node pointer for the next iteration.
// If *node has no next sibling, the returned adress will be 0, in which case the looping condidion will return false and stop looping.
}
For some reason, the code above only outputs the first character of the node name ("h" instead of "hstaticwall"). Would anyone be so kind to tell me why?
EDIT: Sorry, it seems like I had to remove the * before node. It's working.