HAP 不返回任何节点?
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();
}
}
}
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();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
之后它现在可以工作了......
After this its working now.....
为了澄清您的修复,
LoadHtml
需要一个实际 HTML 内容的字符串。Load
从 URL 加载 HTML 内容,这正是您想要的。To clarify your fix,
LoadHtml
expects a string of actual HTML content.Load
loads HTML content from a URL, which is what you intended.