tôi nhận được phản ứng web và sử dụng StreamReader để có được những câu trả lời như là một chuỗicách hiệu quả để tìm chuỗi với StreamReader
mã của tôi là
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string strResponse = reader.ReadToEnd();
mẫu của chuỗi là
<div class="box-round">
<ol style="list-style-type: decimal;list-style-position:outside;margin-left:42px;">
<li>Order ID #A123456 already exists: Update performed
</ol>
</div>
hoặc
<div class="box-round">
<ol style="list-style-type: decimal;list-style-position:outside;margin-left:42px;">
<li>New order created
</ol>
</div>
Tôi muốn xác định vị trí dòng sau trong chuỗi
Order ID #A123456 already exists: Update performed
hoặc
New order created
Đây có phải là cách tốt nhất để tìm kiếm các dòng (s)
while (!reader.EndOfStream)
{
line = reader.ReadLine();
if (!string.IsNullOrEmpty(line))
{
}
}
Bạn' phân tích lại HTML? Nói chung, bạn nên sử dụng trình phân tích cú pháp HTML. [HTML Agility Pack] (http://htmlagilitypack.codeplex.com/) có thể giúp bạn với điều đó. –
Bạn đang tìm loại hiệu quả nào? tức là Bạn đang quan tâm đến việc sử dụng tối thiểu bộ nhớ, cpu hoặc mạng? – Andy
Với quyền hạn là tôi không thể sử dụng HTML Agility PAck – CapsLock