Mr.X
Mr.X

Reputation: 31345

'object' does not contain a definition for 'innerHTML'

I'm using c# mshtml to get html data from a website.

public mshtml.HTMLTableRow tr = default(mshtml.HTMLTableRow);

//do some stuff

tr.cells.item(0).innerHTML

it is recognizing "item" as a generic object. This used to work but now it is giving this error.

Upvotes: 0

Views: 352

Answers (1)

Mauro Bilotti
Mauro Bilotti

Reputation: 6262

I don't know if it is what you want, but if you want to donwload the FULL html from a website, you can do it this way:

using System.Net;
//...
using (WebClient client = new WebClient ()) // WebClient class inherits IDisposable
{
    client.DownloadFile("http://yoursite.com/page.html", @"C:\localfile.html");

    // Or you can get the file content without saving it:
    string htmlCode = client.DownloadString("http://yoursite.com/page.html");
}

Then you can work with the string if you want a certain part of the code. Hope it helps!!

Upvotes: 1

Related Questions