That is what i'm trying to do. I'm just having trouble separating the information that I need from what I don't and putting it into an another ouput file. I'm reading the data into strings.
int secondReading()
{
ifstream In_File;
ofstream Out_File;
string data_text; //variable defined for each line of text from .xml file
string place_indicator; //variable used to locate desired line of text from .xml file
string place_indicator2; //variable used to determine if data is found from desired line of text (data values)
In_File.open("Condensed_Data.dat");
Out_File.open("Condensed_Data2.dat"); //any file format is appropriate for Out_File to be outputted as
getline(In_File, data_text); //pulls first line of text from .xml file
while(In_File)
place_indicator = data_text.substr(0,data_text.find(' ')); //variable defined by first word of each line of text
if(place_indicator == "dataItemId=")
{
Out_File << data_text << endl;
place_indicator2 = data_text.find(">UNAVAILABLE<");
if(place_indicator2 != ">UNAVAILABLE<")
{
getline(In_File, data_text);
Out_File << data_text << endl;
Out_File << endl;
}
else
{
getline(In_File, data_text);
}
}
elseif(place_indicator == "timestamp=")
{
Out_File << data_text << endl;
place_indicator2 = data_text.find(">UNAVAILABLE<");
if(place_indicator2 != ">UNAVAILABLE<")
{
getline(In_File, data_text);
Out_File << data_text << endl;
Out_File << endl;
}
else
{
getline(In_File, data_text);
}
}
elseif(place_indicator == "name=")
{
Out_File << data_text << endl;
place_indicator2 = data_text.find(">UNAVAILABLE<");
if(place_indicator2 != ">UNAVAILABLE<")
{
getline(In_File, data_text);
Out_File << data_text << endl;
Out_File << endl;
}
else
{
getline(In_File, data_text);
}
}
else //if the line does not start with any of the previous...
{
getline(In_File, data_text); //pull next line of text and restart while loop
}
In_File.close(); //file will close; .xml file remains unchanged
Out_File.close(); //file will close; new file is created in project folder; file is now written with what the function has outputted to Out_File
system("pause");
return 0;
}
This is what I have for the code. The program runs without errors but it can't find the specific strings that I need. Because of that nothing is put into the new output file. Any Suggestions?