0

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

Community
  • 1
  • 1
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219

1 Answers1

2

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

doc.DocumentNode.SelectSingleNode("//form[@name='name1']")
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
  • This is very strange. – Tomalak Jul 17 '14 at 15:11
  • @Tomalak - really, I actually tried your suggestion. It gave me the collection of forms, then I tried this code and it did not returned null this time – Zameer Ansari Jul 17 '14 at 15:12
  • 2
    `SelectSingleNode` internally does the same thing `SelectNodes` does. If you get a result with one of the functions, you *should* get a result with the other as well. – Tomalak Jul 17 '14 at 15:14