views:

61

answers:

2

I have webpage I downloaded with C++ to a string, and it is basically a massive <li> list of links. I need to find the last 2 elements of the list. Can anyone help me on how to do this?

+3  A: 

If you are going to do it in a robust way you need an html parser. If the structure of the html is simple enough, and the runtime not an issue, something as stupid as doing string.rfind("<li>") twice might be good enough to find the positions of your elements. Then just do something even more hacky to find the end of each element like look for the next newline

frankc
Alright thank you.
David Powers
A: 

You need to use a dom tree parser to perform this operation reliably.

caskey