开发者

escape character headache

I am trying to use c# to find an html element however I am struggling with the escape characters. My code below is taking an html and trying to find an element within it however start is not returning the IndexOf. What am I doing wrong?

//html im trying to find <table cellspacing="0" cellpadding="0" class="cbParent" summary="Results from your search" id="searchResultsTbl">

        string table = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"cbParent\" summary=\"Results from your search\" id=\"searchResultsTbl\">";
        int sta开发者_Python百科rt = html.IndexOf(table);


You can use single quotes in place of double quotes

"<table cellspacing='0' cellpadding='0' class='cbParent' summary='Results from your search' id='searchResultsTbl'>"

Explanation:
Html attributes may have single quotes ' ' or double quotes " "


You can use

path = @"c:\mypath\temp.dir" 

to use it verbatim. Use double quotes twice to escape it

s = @"Say ""Hello"""


Are you sure it's in the html string?

You can also try placing a @ before the string literal, in which case a double-quote would be accomplished with "" instead of \".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜