Select a node based on name in html agility pack

c# html 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

1
0
5/23/2017 12:23:05 PM

Accepted Answer

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

doc.DocumentNode.SelectSingleNode("//form[@name='name1']")
2
7/17/2014 2:48:20 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow