如何选择</html></身体>;标签
本文关键字:gt lt 身体 标签 html 何选择 选择 | 更新日期: 2023-09-27 18:28:33
这是我的html:
<div id="tab1" class="tab_content">
<div id="dvreadmore"><?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div>
<p class="dgthreedigest">CL : Where petitioner raised same bills against respondent as well as its sister concern, winding up petition against respondent for non-payment of dues was to be dismissed - [2012] 19 taxmann.com 206 (Delhi)</p>
</div>
</body>
</html>
请查看此URL(http://www.taxmann.com/taxmannflashes/whatsnew.aspx?sid=9578&stype=1)
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string htmlResp = sr.ReadToEnd();
String htmlBody = "";
if (htmlResp.ToLower().Contains("<div id='"dvreadmore'">"))
{
int startIndex = htmlResp.ToLower().IndexOf("<div id='"dvreadmore'">");
//here i m getting first index value
// but when i pick last indext it awlays give me -1
int lastIndex = htmlResp.ToLower().IndexOf("</html>'n</div>");
和我在Java编译器中做的一样,选择最后一个索引并给出一定的值,但在C#Asp.Net中,我不能选择数据,它总是给出-1的值。
如何选择最后一个索引?
您必须将lastIndex作为
int lastIndex = htmlResp.ToLower().IndexOf("</html>'r'n</div>");
或
int lastIndex = htmlResp.ToLower().IndexOf("</html>" + Environment.NewLine + "</div");
它返回23195