Select a node based on name in html agility pack

c# html html5 html-agility-pack xpath

Question

I have a form element like this:

<form autocomplete="on" class="class1" action="action1" method="post" name="name1">
</form>

There are 5 forms in webpage, I can access forms using class attribute:

doc.DocumentNode.SelectNodes("//form[@class='class1']")

I am trying to capture this by using name attribute but it is coming null:

doc.DocumentNode.SelectNodes("//form[@name='name1']")

Asking this question as recommended by @Simon

Accepted Answer

(I don't know why but ) This is giving the desired form:

doc.DocumentNode.SelectSingleNode("//form[@name='name1']")


Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why