Reputation: 213
I using HtmlAgilityPack
HtmlAgilityPack.HtmlDocument DocToParse = new HtmlAgilityPack.HtmlDocument();
DocToParse.LoadHtml(HtmlIn);
HtmlAgilityPack.HtmlNode InputNode = DocToParse.GetElementbyId(IDToGet)
This works fine for element that have Id like
<input type="hidden" id="nsv" value="y">
But elements that i need dont have Id only name
<input type="hidden" name="Pass" value="106402333">
<input type="hidden" name="User" value="145">
sow i can't use
HtmlAgilityPack.HtmlNode InputNode = DocToParse.GetElementbyId(IDToGet)
and there is no method GetElementbyName,sow any one know how i can get element by Name?
Upvotes: 2
Views: 1690
Reputation: 2204
You may use XPath selector:
var nodes = DocToParse.DocumentNode.SelectNodes("//input[@name='" + NameToGet + "']");
Upvotes: 5