how to use
(1)strtok to find out html tags from a file?
(2)getline(a,b,'<>');
is the getline method used correctly? If not how should I use getline to clean up all html tags in a file...
Thanks alot... Appreciate your help.
I don't think you can use strtok to parse HTML.
getline reads a line from a stream, a line being all characters upto the EOL delimiter defaulted to '\n'. That's all it does.
HTML tags are 'nested' so its not as simple as finding every '<' and '>'. You need to record the 'depth' of tag as you go.
Certainly getline() could be useful in that process. But not how you are using it. You would need to do something like this:
1 2 3
|
std::string data;
std::getline(in, data, '<'); // find start of tag descriptor
std::getline(in, data, '>'); // find end of tag descriptor
| |
You would need extra logic to determine the start tags from the end tags and to keep track of the nesting.
Last edited on