using System;
using BankNew;
using HtmlAgilityPack;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
//source.Deposite(float.Parse(txtBox1.Text));
//source.TransferFunds(destnation, float.Parse(tbWithdraw.Text));
//lblBalance.Text = source.Balance.ToString();
HtmlDocument htmlDoc = new HtmlDocument();
string filePath = "http://localhost:50846/Website/TestSourceCode.txt";
// There are various options, set as needed
// filePath is a path to a file containing the html
htmlDoc.LoadHtml(filePath);
if (htmlDoc.DocumentNode != null)
{
// HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("/body");
HtmlNodeCollection links=htmlDoc.DocumentNode.SelectNodes("//a");
foreach (HtmlNode node in links )
{
string title = node.InnerText;
// txtBox1.Text = title;
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
Response.End();
}
}
}
答案 0 :(得分:0)
此后它正在工作.....
HtmlWeb web = new HtmlWeb();
HtmlDocument htmlDoc = web.Load("http://localhost/Website/TestSourceCode.htm");
答案 1 :(得分:0)
为了澄清您的修复,LoadHtml
需要一串实际的HTML内容。 Load
从网址加载HTML内容,这正是您的意图。