Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is an excerpt from the text file.
the substring to searched for is 'subject short'
I need to print in another file, name of the subject which is within the quotes after the substring and also the id next to it.

<subject short="Savremeni oksidni i neoksidni materijali-V" name="ICM47-V" id="D44D06A2ED25C9C3" partner_id=""/>

<subject short="Biokeramicki materijali-P" name="ICM49-P" id="CD0687B09D5CE7C8" partner_id=""/>

<subject short="Biokeramicki materijali-V" name="ICM49-V" id="E9E661064763C3D9" partner_id=""/>

<subject short="Korozija i zaštita materijala-V" name="14IIM41-V" id="5AF2BF5C810D5D98" partner_id=""/>

<subject short="Uvod u hemijsko inženjerstvo-V" name="14HHI210-V" id="8CE923B31C35DB61" partner_id=""/>



What I have tried:

I have tried doing it, but nothing seems to work.
Posted
Updated 2-Jul-18 0:36am
Comments
Patrice T 2-Jul-18 11:15am    
your problem is that you have no code.

You have to parse the text. You may either use raw strtok[^] calls or a regex library. Please note, since C++ 11, regular expressions are part of the STL: <regex> - C++ Reference[^].
 
Share this answer
 
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Quote:
I have tried doing it, but nothing seems to work.
I can only assume you did not do the right things.
Selecting the correct functions or classes to read the file is the first thing to do. So start by writing the code to do just that. Read each line from the file and display it on the console or window, depending on the type of program you are writing. Once you have that working then add the code to check each line for the keywords you want, and display just the lines with the correct keywords. Once you have that working, then add the code to split the lines and display just the content that you want from each line. Build your application piece by piece and you will find it much easier.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900