precompile xpath queries

Topics: Developer Forum
Mar 26, 2007 at 9:49 AM
I'm parsing 7000+ HTML pages. Each has a common table that is extracted and processed for information. Currently, I am retrieving the data using the SelectNodes method of HtmlNode object. Is there a way to precompile or cache the query to SelectNodes to speed things up across each URL request?

Jul 30, 2007 at 6:08 AM
hi sir
i need to login programattically and scrapping data from a website which is the next page after login .
for this i m using html agility pack.
i m using the link
as reference .
for trial i m trying to login in gmail and code is as following........................
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
FormProcessor p = new FormProcessor();
string userName = "*****************";
string password = "******************";
Form form = p.GetForm("","//form@name='loginForm'", FormQueryModeEnum.Nested);
form"j_username".SetAttributeValue("value", userName);
form"j_password".SetAttributeValue("value", password);
HtmlDocument doc = p.SubmitForm(form);
string strBal = doc.DocumentNode.SelectSingleNode
strBal = System.Web.HttpUtility.HtmlDecode(strBal);
strBal = strBal.Substring(1).Trim();

in which i m facing problem in xpath //form@name='loginForm' the error is node not found.
i want to know that how can i compose the xpath for any website . plz tell me complete reference about it.

thanks in advance

sharad soni
Jul 30, 2007 at 6:08 AM
Edited Jul 30, 2007 at 6:12 AM