I use this code to find CDEin HTML. How can I find my request data on a tag page with different identifiers, for example, if page ID is 1 , my result is CDE and when page ID 2 is my IJK result . How to set id value in my search?
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.DocumentText = @"<html><head><title></title></head><body>"
+ "<page id=\"1\">"
+ @"ABCDEF</page>"
+ "<page id=\"2\">"
+ @"GHIJKLMN</page></body></html>";
webBrowser1.DocumentCompleted += HtmlEditorDocumentCompleted;
}
void HtmlEditorDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var document = (IHTMLDocument2)((WebBrowser)sender).Document.DomDocument;
if (document != null)
{
IHTMLBodyElement bodyElement = document.body as IHTMLBodyElement;
if (bodyElement != null)
{
IHTMLTxtRange trg = bodyElement.createTextRange();
if (trg != null)
{
trg.move("character", 2);
trg.moveEnd("character", 3);
trg.select();
trg.pasteHTML("<font color=#FF0000><strike>" + trg.text + "</strike></font>");
}
}
}
}
source
share