Hey
.NET 3.5
I'm trying to search a string to determine if the string contains </table>,
but string.Contains don't find it. I've used WebRequest/WebReponse to
retrieve the html from a webpage and now I'm searching through this html...
this webpage contains 4 html tables. so there are 4 </table>, but my code
don't find any...
Here is part of my code, this if-statment don't get true...
string line;
if (line.Contains(" </table>" ))
{
boolean = false;
}
any suggestions?
Jon Skeet [C# MVP] - 10 Mar 2008 15:57 GMT
> I'm trying to search a string to determine if the string contains </table>,
> but string.Contains don't find it. I've used WebRequest/WebReponse to
[quoted text clipped - 10 lines]
>
> any suggestions?
Did you mean to look for " </table>" including a leading space?

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jeff - 10 Mar 2008 16:35 GMT
opps, my typo when creating this post.
I mean:
if (line.Contains( "</table>" ))
{
boolean = false;
}
>> I'm trying to search a string to determine if the string contains
>> </table>,
[quoted text clipped - 14 lines]
>
> Did you mean to look for " </table>" including a leading space?
Jon Skeet [C# MVP] - 10 Mar 2008 16:40 GMT
> opps, my typo when creating this post.
> I mean:
> if (line.Contains( "</table>" ))
> {
> boolean = false;
> }
Well, if you've got a line which contains "</table>" that will
certainly find it.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Marc Gravell - 10 Mar 2008 16:05 GMT
Might also want to check the source to see if it uses some other
casing: TABLE, Table, tAbLe, etc... depending on your conformance,
anything is possible...
Jeff - 10 Mar 2008 16:57 GMT
I've just found out why this didn't work. My mistake... the reason if
(line.Contains("</table>" )) didn't work, was because there is another
if-statement above this and that if statement wasn't true... so I've solved
it.
> Hey
>
[quoted text clipped - 14 lines]
>
> any suggestions?
Christopher Van Kirk - 11 Mar 2008 07:00 GMT
>Hey
>
[quoted text clipped - 14 lines]
>
>any suggestions?
Check that you haven't put \t instead of /t.

Signature
Posted via a free Usenet account from http://www.teranews.com
Robert Everett - 15 Mar 2008 07:49 GMT
Contains is case sensitive. You will have to try something like:
string myString = "<Table><TR><TD></TD></TR></Table>";
if (myString.ToUpper().Contains("</TABLE>"))
{
Console.WriteLine("Found it.");
}
or you could use regular expressions.
>>Hey
>>
[quoted text clipped - 18 lines]
>
> Check that you haven't put \t instead of /t.