How to get count number of SelectedNode with XPath in C#?
-
I am using HTMLAgilityPack in my application, and i want to get the item(node) count of SelectedNodes as the code below: HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(webBrowser1.DocumentText); var tagListe = doc.DocumentNode.SelectNodes("//a[@href]"); var divListe = doc.DocumentNode.SelectNodes("//div[@class='o']"); At the first, getting a href was successfully running, but second one i prefer to get special class named "o" there was en error. I want to use .Count but got an error. Also foreach loop running for the firs selectedNodes which i request a tags href attribute. And didn't run for class filtering. Hot to get count of doc.DocumentNode.SelectNodes("//div[@class='o']") Thank you, Caglar
-
Answer:
I don't know the specific way in HTMLAgilityPack but in plain XPath you can do this: count(//div[@class='o']) You properly can't use this XPath in .SelectNodes but there should be a method like Evaluate, SelectSingle or SelectAtom.
caglaror at Stack Overflow Visit the source
Related Q & A:
- How To Get Girls Mobile Number?Best solution by Yahoo! Answers
- How to count number of occurrences of pattern within a string?Best solution by Stack Overflow
- How to get line number from .NET pdb?Best solution by Stack Overflow
- How to get Count of each Column value of table?Best solution by Stack Overflow
- How to get a C.L.U.E. report?Best solution by realestate.about.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.