With some help I've almost completed a program which enables me to extract the timestamps(eg:timestamp="2014-07-08T18:14:16.468Z" ) and only the timestamps from and XML file and output them to a designated output file. However, there are a handful of errors left in my code which have me at wits end, which can't seem to redress. Would someone more experienced with C++ mind helping me out? The errors appear in lines 35,38, & 47.
Screenshot of errors: http://i.imgur.com/jVUig4T.jpg
Link to XML file: http://pastebin.com/DLVF0cXY
#include <iostream> #include <string> #include <fstream> using namespace std; int main() { using namespace std; string tempStr; // escaped double qoute. string findStr = "timestamp=\""; ifstream inFile; ofstream outFile; outFile.open("Outputdata.txt"); inFile.open("Groupproject.xml"); if (inFile.fail()) { cout << "Error Opening File" << endl; system("pause"); exit(1); } size_t found; while (inFile) { getline(inFile, tempStr); found = tempStr.find(findStr); if (found != std::string::npos) { break; } } // Erases from beggining to end of timestamp=" tempStr.erase(tempStr.begin(), (found + tempStr.length())); // Finds index of next double qoute. found = tempStr.findStr("\""); if (found = std::string::npos) { cerr << "Could not find matching qoute:"; exit(1); } // Erases from matching qoute to the end of the string. tempStr.erase(found, tempStr.end()); cout << "timestamp found" << tempStr << "Saving to outFile" << endl; outFile << tempStr; inFile.close(); outFile.close(); system("pause"); return 0; }
No comments:
Post a Comment