特定のフィールドを抽出したいxmlファイルがあります
サンプル テスト ファイル
<ScheduleTask ID="ZmwnBtczlnYOBLyK" Code="000-000.0.0.0" Name="SETTLEMENT.BRIDGE" ParentSummaryTaskID="">
<Quantities>
<STQuantity MethodID="416" RecipeID=""/>
</Quantities>
<Timings>
<Timing LocationID="$$$$$>C1>NB" CompletionRate="1">
<Planned Begin="2012-03-08T07:14:57" End="2012-03-28T07:14:57"/>
<Actual Begin="2012-03-31T06:00:00" End="2012-05-01T14:00:00"/>
</Timing>
<Timing LocationID="$$$$$>C1>SB" CompletionRate="0">
<Planned Begin="2012-12-04T06:07:29" End="2012-12-24T06:07:29"/>
<Forecast Begin="2013-04-18T09:16:37" End="2013-06-04T12:06:02"/>
</Timing>
</Timings>
</ScheduleTask>
したがって、/ScheduleTask (< を含む) を含む行を検索するこの関数があります。
//xml file into ontology
list<stack<string> > addWordsFromFile(string filename, int changeLevel)
{
ifstream ontology;
ontology.open(filename.c_str());
string ontTemp, line;
list<stack<string> > control_list;
while (true) {
getline(ontology, line); //read line
if (ontology.fail()) break; //boilerplate check for error
line.erase(remove(line.begin(), line.end(), '\t'), line.end()); //remove tabs
if(line == "</ScheduleTasks>") break; //check for end of document
if(line == "</ScheduleTask>") {
ontTemp.clear(); //clear memory
}
//look for activity
if(line.substr(1, 15) == "ScheduleTask ID") {
int i = 41;
while (line[++i] != '"') {ontTemp += line[i]; }
}
if (ontTemp != "" ) {//ready to add
stack<string> tempMem;
tempMem.push(ontTemp);
control_list.push_back(tempMem);
}
}
ontology.close();
return control_list;
}
Windows では、この関数は正常に機能し、/ScheduleTask
見つかった - Linux では見つからなかったが、他のフィールドはif(line.substr(1, 15) == "ScheduleTask ID")
VisualStudio 2008 および g++ でコンパイル
私の質問: 1) これが Linux で機能しないのはなぜですか? 2) どのように機能するのですか?