Reputation: 65
I need to get a value from an input, but the id always change, only the name is the same. Didn't found anything on google to extract the value by the name tag.
Example:
<input type="hidden" name="data[_Token][key]" value="5aafaee2dd21555c2615fd26c0cccd0f1b2c3018" id="Token749368899" /></div>
I look forward to some answers.
Upvotes: 1
Views: 802
Reputation: 116168
var input= doc.DocumentNode
.Descendants("input")
.First(n=>n.Attributes["name"].Value=="data[_Token][key]");
Upvotes: 3
Reputation: 3117
Try this
var dummy = document.getElementsByName("data[_Token][key]");
This will return you elements which has name "data[_Token][key]".
Upvotes: -1
Reputation: 5126
You can try getting the first part of Id, if it's always Token#####
//input[starts-with(@id, 'Token')]
Upvotes: 0