G
G
georgich2017-06-13 09:31:04
C++ / C#
georgich, 2017-06-13 09:31:04

What is the necessary condition for fetching xpath?

Greetings.
I parsed one site using the HtmlAgilityPack library. The following code was written:

var node = document.DocumentNode.SelectNodes("//tr[not(@class)]/td[@style='width:1%;' or @class='coef' or (@class='left' and .//a)]");

But, as it turned out, unnecessary data also fall under this condition. I figured out that I needed to add a condition to the xpath that would check if tr contains 18 td . Can you please tell me how to add this condition to my design?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-06-13
@georgich

Try

var node = document.DocumentNode.SelectNodes("//tr[not(@class) and count(td) = 18]/td[@style='width:1%;' or @class='coef' or (@class='left' and .//a)]");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question