c# - Html table on Html page - NO XML -
i'm trying grab data html table on website. no xml involved.
<table id="e-cal-table" class="e-cal-table" width="100%"> <tr> <th>date</th> <th>time</th> <th>currency</th> <th>event</th> <th>importance</th> <th>actual</th> <th>forecast</th> <th>previous</th> <th>notes</th> </tr>
the following results in "object reference not set instance of object."
htmlagilitypack.htmldocument doc = new htmlagilitypack.htmldocument(); doc.loadhtml("http://www.example.com"); string table = doc.documentnode.selectsinglenode("//table[@id='e-cal-table']").innertext;
i'm @ loss how identify table future parsing. unfortunately, examples i've been able find have xml.
your code works if load doc string
.
if want load url use doc.load(url);
not doc.loadhtml(htmlstring);
--edit--
sorry, bad, doc.load
doesn't accept http
can use this
using (var wc = new webclient()) { doc.loadhtml(wc.downloadstring(url); }
Comments
Post a Comment