views:

48

answers:

1

I'm trying to get started with HtmlAgilityPack and was wondering if someone could help me get off to a good start.

I'm trying to access the user1 id and the password1 id from the url https://www.foragentsonly.com/login.aspx

How would I go about that?

A: 

Given that you have the HTML document already, this should work:

HtmlDocument doc = new HtmlDocument();
doc.Load("file.htm");
doc.DocumentElement.SelectNodes("//input[@id=user1]");
doc.DocumentElement.SelectNodes("//input[@id=password1]");

It just works off standard xpath syntax, so for more complex queries, use this reference as a guide.

jvenema
And is it possible to select the image1 tag and submit the values?
mstrickland
To select the image1 tag, sure. Same thing, just modify the selector a bit. To submit the values - that's a different question, and has nothing to do with the agility pack. You'll need to create a web request, etc, for that.
jvenema