in reply to Re: How do I select text between two bits of text?
in thread How do I select text between two bits of text?
Use of a style or span tag, among others, is legit... and a complication for which you'll want to allow unless you can be absolutely positive from now till the heat death of the universe, that no such element will appear in the hmtl you're parsing.I strongly disagree with the sentiment. By all means, if you're paying for your own time, feel free to make the effort to write extremely defensive code, that will last forever.
Often though, it makes less sense. See, every minute you spend coding for something that may happen between now and the end of the universe, is a wasted minute if said thing never happens, or it doesn't happen until the program is obsoleted. A minute you could have spend writing something that actual scratches a current itch, solves a problem that needs fixing now, or something that will make money right now.
In this case, I don't think we'll be generating or parsing HTML 4.01 a few decades from now; 75% will be "tag soup, but at least it works on IE 6", 20.9% will work on the designers setup, and only on the designers setup, 4% will not work anywhere, nor does it follow any known standard, and the remaining 0.1% has made an attempt to follow a newer standard.
That having said, it may (or may not) make sense for the OP to cater for such an element appearing in the HTML text. But without knowing more about the context, I can't say for sure.
|
|---|