I am writing a C# forms application, that deals with a html document. I have a List of objects, where each object has an XPath for a html node.
When adding a html node, the XPath for these above objects changes.
My question is this: How is the best way to update all XPath values, after making an addition to a document? I am currently using Html Agility Pack.
EDIT
I have tried the following in code, but am not sure if Html Agility Pack has this feature, or I may be writing my code incorrectly:
- Before making any changes to the HtmlDocument, create a HtmlNode object for each XPath that I have
- Insert the new HtmlNode
I am creating the HtmlNodes with the following code:
HtmlNode htmlNode1 = testingHtmlDocument.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]");
- Should the XPath values in each of the HtmlNodes be updated after an addition has been made to the HtmlDocument? Does XPath work this way?
- Other than XPath, what is the best way to identify a HtmlNode, without adding any additional data to a HtmlNode?
Thanks.