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:
I am creating the HtmlNodes with the following code:
HtmlNode htmlNode1 = testingHtmlDocument.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]");
Thanks.
If you need to update the XPaths every time, you probably use indexing. And if you need to make changes often, maybe that is not the best way to go. Maybe you can add an ID to the tags? Then you could use: "//*[@id='0123-654-97854']"
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加