I am trying to use HTMLAgilityPack with VS2008/.Net 3.5. I get this error
An unhandled exception of type 'System.Exception' occurred in HtmlAgilityPack.dll
Additional information: You need to set UseIdAttribute property to true to enable this feature
This is the code;
public string kmail = "deneme";
public string ksifre = "deneme123";
private void button2_Click(object sender, EventArgs e)
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.GetElementbyId("username_or_email").SetAttributeValue("Value", kmail);//bilgileri gir
doc.GetElementbyId("password").SetAttributeValue("Value", ksifre);
HtmlElement button = Browser.Document.GetElementById("allow");//tıkla
button.InvokeMember("click");
}
I tryed old versions of DLL but didn't worked.
How can I fix this issue? Thanks.
You may be able to resort to use SelectSingleNode()
passing XPath to select node by id
attribute, for example :
doc.DocumentNode
.SelectSingleNode("//*[@id='password']")
.SetAttributeValue("Value", ksifre);