-
March 12th, 2015, 08:57 AM
#16
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
-
March 12th, 2015, 10:50 AM
#17
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) ?
-
March 12th, 2015, 11:26 AM
#18
Re: parse a .xml with just C++ Standard Library
Originally Posted by flex567
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|