terminate called after throwing an instance of 'rapidxml::parse_error'<br /> what(): expected ' or "
xml_document<> doc; xml_node<> * rootNode; //read the xml file into vector ifstream xmlFile("Exchange.xml"); xmlFile.unsetf(ios::skipws); vector<char> buffer ((istreambuf_iterator<char>(xmlFile)), istreambuf_iterator<char>()); buffer.push_back('\0'); //Parse the buffer doc.parse<0>(&buffer[0]); //getting the root node rootNode = doc.first_node("Exchange"); //Iterating through the file xml_node<> * sourceId; for(sourceId = rootNode->first_node("sourceId"); sourceId; sourceId = sourceId->next_sibling()){ cout << sourceId->value() << " : " << sourceId->first_attribute("interval")->value() << endl; }
<pre><?xml version="1.0" encoding="UTF-8"?> <Exchange> <sourceId interval = 03>ADSM<sourceId/> <sourceId interval = 06>ASE<sourceId/> <sourceId interval = 09>BSE<sourceId/> <sourceId interval = 12>CSAE<sourceId/> <sourceId interval = 15>CSE<sourceId/> <sourceId interval = 18>TDWL<sourceId/> </Exchange>
NOTE: The above code is in a single method which calls in the main method. I just want to print the attribute value and the child value of the nodes. How can I solve this? Thank you!
//read the xml file into vector file<> xmlFile("Exchange.xml"); //Parse the buffer doc.parse<0>(xmlFile.data());
XML
Quote:<Exchange> <sourceId interval = 03>ADSM<sourceId/> ...
/
<Exchange> <sourceId interval="03">ADSM</sourceId>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)