[英]escape character headache
我正在尝试使用c#来查找html元素但是我正在努力使用转义字符。 我的下面的代码是一个html并尝试在其中找到一个元素,但是start并没有返回IndexOf。 我究竟做错了什么?
//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 start = html.IndexOf(table);
您可以使用单引号代替双引号
"<table cellspacing='0' cellpadding='0' class='cbParent' summary='Results from your search' id='searchResultsTbl'>"
说明:
Html属性可能有单引号' '
或双引号" "
您可以使用
path = @"c:\mypath\temp.dir"
逐字使用它。 使用两次双引号将其转义
s = @"Say ""Hello"""
你确定它在html
字符串中吗?
你也可以尝试在字符串文字之前放置一个@
,在这种情况下,双引号将用""
代替\\"
来完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.