C# Parsing hidden fields with the HTML Agility Pack

5.1k Views Asked by At

I need to write an application for a friends site which parses hidden fields. I've downloaded the Html Agility Pack library, but I'm kinda confused because there are not really any examples. The HTML field looks like this:

<input type = "hidden" autocomplete="off" value="randomvalue" name="foo">

How would I go about getting the value from this field?

1

There are 1 best solutions below

0
On BEST ANSWER

from memory, something like:

var value = docroot.SelectSingleNode("//input[@type='hidden' and @name='foo']")
                .Attributes["value"].Value;