Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:18:24+00:00 2026-06-18T03:18:24+00:00

I have an xml file that I want to extract some specific fields from

  • 0

I have an xml file that I want to extract some specific fields from

Sample test file

<ScheduleTask ID="ZmwnBtczlnYOBLyK" Code="000-000.0.0.0" Name="SETTLEMENT.BRIDGE" ParentSummaryTaskID="">
    <Quantities>
        <STQuantity MethodID="416" RecipeID=""/>
    </Quantities>
    <Timings>
        <Timing LocationID="$$$$$&gt;C1&gt;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="$$$$$&gt;C1&gt;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>

So, I have this function that looks for a line with /ScheduleTask (includes the <)

//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;
}

In windows this function works fine and the /ScheduleTask is found – in Linux it is not found, though other fields are found just fine with if(line.substr(1, 15) == "ScheduleTask ID")

compiled with VisualStudio 2008 and g++

My question: 1) why doesn’t this work in Linux and 2) how does it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:18:26+00:00Added an answer on June 18, 2026 at 3:18 am

    This comes down to the definition of the end of a line. Windows EOL is \r\n while Linux EOL is \n. So the line

    </ScheduleTask>\r\n
    

    comes back from getline as

    </ScheduleTask> on Windows but </ScheduleTask>\r in Linux.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to parse text from a xml file.Consider that I have a some
I have an XML file in which I want to extract data from certain
I have an xml file that I want to configure using a bash script.
I have a single XML file that I want to index using Lucene.NET. The
I have a flash applet that I want to grab a remote XML file
I have a ListView that is populated using an XML file. However, I want
I have an XML file that I'm trying to read from here , and
i have the following question: I have a XML file with some elements that
I have a XML file that has the following data, <extcode Type=abc Code=12345 />
I want to convert xml file using xsltproc and only extract some portions of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.