After successfully installing the Html Agility Pack to my asp.net project, I have been able to extract data from a different web page and display it without any issues. However, I am currently facing a problem. I have identified a div with the id of header, within which there is another div with the class name login that I want to remove. Below is the code snippet I am using:
//Get the div with the id of footer
HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@id='header']");
//Remove login div
HtmlNode loginSection = node.SelectSingleNode("//div[@class='login']");
node.RemoveChild(loginSection);
Although the loginSection variable does contain a value at this point, indicating that the selected div exists, I encounter an error when trying to call the RemoveChild function:
Node "<div class="login"></div>" was not found in the collection
Despite searching for solutions on stackoverflow, I have yet to find a resolution to this issue.