I stand corrected. SelectNodes
does return null
if it can't find any nodes.
But the behavior you are witnessing has nothing to do with the id
attribute (in fact, removing the id
attribute causes an exception to happen sooner), and everything to do with your code.
At the end of your inner loop, you are doing this:
getInputSchedule[i].Remove();
which removes the <input>
element from the HTML document.
Your outer loop is set up to execute four times, so the second time it executes, the input
element is already gone, and doc.DocumentNode.SelectNodes("//table//input")
returns null
, and that is the cause of your error.
I'm not really sure why you're removing the input
elements from the document as you go through it, or why you're looping through the whole thing 4 times, but hopefully that gets you going in the right direction.