c++ count html tags

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: c++ count html tags

 
0
  #11
Apr 5th, 2009
You could tokenize (strtok) by "<" and stick each piece into a vector or so... then get it's size().
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: c++ count html tags

 
0
  #12
Apr 5th, 2009
Originally Posted by Comatose View Post
You could tokenize (strtok) by "<" and stick each piece into a vector or so... then get it's size().
That sounds like the hard way. strtok() embeds NULLs in the string, which might corrupt the std::string class.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: c++ count html tags

 
1
  #13
Apr 5th, 2009
>You could tokenize (strtok) by "<" and stick each piece into a vector or so... then get it's size().

Best not to mix c with c++. Naughty naughty :-0

In any case all these suggestions are too niave. There are a few examples which will slip through the loop, (html attributes)

http://haacked.com/archive/2004/10/2...matchhtml.aspx

So using regular expressions, would be the best way to deal with this however, if this is homework your professor is unlikely to care.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 8
Reputation: mat1989 is an unknown quantity at this point 
Solved Threads: 0
mat1989 mat1989 is offline Offline
Newbie Poster

Re: c++ count html tags

 
0
  #14
Apr 6th, 2009
I got it working guys Code I used below :

  1.  
  2. if (c=='<' )
  3.  
  4. {
  5.  
  6. istag = true;
  7.  
  8. }
  9.  
  10. if (c== '>' && istag == true)
  11.  
  12. {
  13.  
  14. amounttag++;
  15. istag = false;
  16. }
  17.  
  18.  
  19.  
  20.  
  21. if (c== '!')
  22.  
  23. {
  24.  
  25. iscomment = true;
  26.  
  27. }
  28.  
  29. if ( c== '-' && iscomment == true)
  30. {
  31. amountcomment++;
  32. amounttag --;
  33. iscomment = false;
  34.  
  35. }

works a treat , Thanks for all your help.
Last edited by mat1989; Apr 6th, 2009 at 12:51 pm. Reason: code nbt displaying correct
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 621
Reputation: Xlphos is an unknown quantity at this point 
Solved Threads: 74
Xlphos's Avatar
Xlphos Xlphos is offline Offline
Practically a Master Poster

Re: c++ count html tags

 
0
  #15
Apr 9th, 2009
I think I am doing the same assignment as you. Dont forget there maybe an exclamation mark in normal text. "Hello!" you would be better saying if '<' precedes '!' then add 1 to comment count.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC