|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I have to parse this XML text file
and store the items in a song object sample text file <song> <id>2390</id> <name>Nolita Fairytale</name> <artist>Vanessa Carlton</artist> <composer>Vanessa Carlton and Stephan Jenkins</composer> <album>Heroes & Thieves</album> <genre>Pop</genre> <year>2007</year> <type>WAV</type> <sample rate>96000</sample rate> <length>19698000</length> </song> song createSong(FILE* xmlLibrary); song* creatLibrary(FILE* xmlLibrary, int* count); the create Library function is supposed to use Create song to store the album, year, genre, ...etc into a song structure and store a song into a array(text file will have more than one song) me and friend tried using some C++ stuff, but then my teacher said no to that... :*( ne help would be appreciated
__________________
On C/C++ I use MS Visual Studios 2005 Express (yuck) On Java I use BlueJ (Rocks!) |
| Sponsored Links |
|
|
|
|||
|
have to do everything myself
![]() hmm its actually an xml file god i hate this class ![]()
__________________
On C/C++ I use MS Visual Studios 2005 Express (yuck) On Java I use BlueJ (Rocks!) Last edited by Salrandin; 10-24-2007 at 04:43 PM. |
|
|||
|
Well it's not very difficult. Here's my pseudocode
- Fuction ExtractTag(tagname), returns a char* Scan the file for the song tag <tagname>, mark this position X Then scan the song for the end song tag </tagname>, mark this position Y. Extract whatever is in-between these two positions X and Y and call this CONTENTS. First scan for the tag <song>, and extract its contents, also have an array containing the tags you want to extract, e.g. char* tags = {"id","name", whatever}; for each tag name in tags[], use ExtractTag to get its contents from CONTENTS and store it into a struct. Then jump to the next position after each complete song has been read and keep reading until EOF |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I dont understand this parser code | Salrandin | C and C++ | 3 | 10-24-2007 12:56 AM |
| Serial controller algorithm | kenneth_888 | C and C++ | 1 | 09-13-2007 11:16 AM |
| Help in SLR parser | vithasekar | C and C++ | 3 | 02-15-2007 02:50 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |