Html Agility Pack Get All Input Fields
I found some code on the internet that finds all the href tags and changes them to google.com, but how can I tell the code to find all the input fields and put custom text in there
Solution 1:
Change the XPath selector to //input to select all the input nodes:
foreach (HtmlNode inputin doc.DocumentNode.SelectNodes("//input"))
{
HtmlAttribute att = input.Attributes["value"];
att.Value = "some text";
}
Solution 2:
Your current code selected all a elements (that have a href attribute): "//a[@href]".
You want it to select all input elements: "//input".
Of course, the inner part of the loop will need to change to match what you are looking for.
I suggest you read up on XPath.
Post a Comment for "Html Agility Pack Get All Input Fields"