943,650 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2097
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Apr 5th, 2009
0

Re: c++ count html tags

You could tokenize (strtok) by "<" and stick each piece into a vector or so... then get it's size().
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Apr 5th, 2009
0

Re: c++ count html tags

Click to Expand / Collapse  Quote originally posted by Comatose ...
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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,949 posts
since Aug 2005
Apr 5th, 2009
0

Re: c++ count html tags

>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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Apr 6th, 2009
0

Re: c++ count html tags

I got it working guys Code I used below :

C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mat1989 is offline Offline
8 posts
since Apr 2009
Apr 9th, 2009
0

Re: c++ count html tags

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.
Reputation Points: 32
Solved Threads: 116
Veteran Poster
Xlphos is offline Offline
1,073 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Simple Quadratic Equation Solver - C++ - Do You Have Any Advices Would Like to Give?
Next Thread in C++ Forum Timeline: fstream to int





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC