Em có đoạn HTML sau:
<table cellpadding="0" cellspacing="0" id="id_tbl" class=" cke_show_border">
<tbody>
<tr>
<td>
<span class="title_editor">Heading</span>
</td>
</tr>
<tr>
<td class="content_tbl" id="id_td">
<p align="center" style="text-align:center; margin:0in 0in 0.0001pt">
<span style="font-size:14pt">
<span style="line-height:150%">
<span style="font-family:"Times New Roman",serif">
<b>hello world < /b>
</span>
</span>
</span>
</p>
</td>
</tr>
</tbody>
</table>
Giờ em muốn lấy chữ “hello world” thì phải làm thế nào ạ.
Em copy xpath thì được thế này: //*[@id="id_td"]/p/span/span/span/b/text(). Em đã thử như sau, em dùng HtmlAgilityPack:
string curUrl = geckoWebBrowser1.Url.ToString();
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load(curUrl);
var nodes = doc.SelectNodes("//*[@id='id_td']/p/span/span/span/b/text()");
richTextBox1.Text = nodes.ToString();
Nhưng vẫn không được, có bác nào giúp em dùng hướng nào để lấy được chữ không ạ. Em cảm ơn nhiều.
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?