CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,117

    Re: parse a .xml with just C++ Standard Library

    the difference between the chosen course and the one in a file on a specific date
    This could be done *without* actually parsing the XML file [think how various text comparison programs work]...I wonder if such an approach would be accepted.

    As stated previously, writing an XML Parser is a HUGE undertaking. Writing a parser for a fixed file format (which might happen to be XML) is a different task...

    You are 100% correct in "I think I first have to figure out what exactly should this program do."
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  2. #17
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    Re: parse a .xml with just C++ Standard Library

    Writing a parser for a fixed file format (which might happen to be XML) is a different task...
    Do you have an example of a program that parses a fixed file format ( .xml file) ?

  3. #18
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,117

    Re: parse a .xml with just C++ Standard Library

    Quote Originally Posted by flex567 View Post
    Do you have an example of a program that parses a fixed file format ( .xml file) ?
    Sure...(this was typed in here, so errors are likely)

    Code:
    int main () {
      string line;
      ifstream myfile ("example.txt");
      int line = 0;
      if (myfile.is_open())
      {
        while ( myfile.good() )
        {
          getline (myfile,line);
          if (++line == 10)  // Important content is on line 10...
          {
              value = line.substr(8, 12); // get the content from the relevant part of the line.
              cout << value<< endl;
          }
        }
        myfile.close();
      }
    
      else cout << "Unable to open file"; 
    
      return 0;
    }
    I posted this *only* because it would technically meet the requirements of being a "parser" and with the right values handle an XML input format.....but it would almost certainly no be usable for anything real world..
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured