Здравствуйте, Аноним, Вы писали:
А>Везде InvalidCastException. Как нужно правильно?
Извинямса!
Вот рабочий пример:
static void Main(string[] args)
{
HTMLDocumentClass document = new HTMLDocumentClass();
IHTMLDocument2 idoc = document as IHTMLDocument2;
if(idoc != null)
{
idoc.write("<html><body><a href=\"http://www.sex.com/1.html\">1</a><a href=\"http://www.sex.com/2.html\">2</a><a href=\"http://www.sex.com/3.html\">3</a></body></html>");
Console.WriteLine(idoc.body.innerHTML);
IHTMLElementCollection col;
IHTMLAnchorElement this_link;
col = idoc.links;
foreach(object link in col)
{
if(link is IHTMLAnchorElement)
{
this_link = (IHTMLAnchorElement)link;
if(this_link.href == "http://www.sex.com/3.html")
{
this_link.href = "http://www.sex.com/4.html";
}
}
}
Console.WriteLine("\n_________________________________________________________________\n");
Console.WriteLine(idoc.body.innerHTML);
}
}