Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-2007, 11:19 PM
Salrandin Salrandin is offline
Newbie
 
Join Date: Oct 2007
Posts: 10
Rep Power: 0
Salrandin is on a distinguished road
Send a message via AIM to Salrandin
Default Im at my wits end with this XML parser!

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!)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-24-2007, 12:37 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

When you say, your teacher said that you couldn't use C++, I suppose you've to do it in C?

For both language, you'll find a lot of XML-parsers - or do you've to do everything yourself?
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-24-2007, 04:36 PM
Salrandin Salrandin is offline
Newbie
 
Join Date: Oct 2007
Posts: 10
Rep Power: 0
Salrandin is on a distinguished road
Send a message via AIM to Salrandin
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-25-2007, 02:45 AM
limo limo is offline
Newbie
 
Join Date: Oct 2007
Location: Australia
Posts: 14
Rep Power: 0
limo is on a distinguished road
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-26-2007, 10:10 AM
Salrandin Salrandin is offline
Newbie
 
Join Date: Oct 2007
Posts: 10
Rep Power: 0
Salrandin is on a distinguished road
Send a message via AIM to Salrandin
Default

o ok i see this thx!
__________________
On C/C++ I use MS Visual Studios 2005 Express (yuck)
On Java I use BlueJ (Rocks!)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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


All times are GMT -5. The time now is 04:09 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads