Solution 1 :

According to the doc you have to use findElements with a s. If I modify a bit your XPath, you can have something like this :

const nodes = xpath.fromPageSource(html).findElements("//a[@class='classifiedTitle']");
console.log("Number of ads found:", nodes.length);
console.log("Link[0]:", nodes[0].getAttribute("href"));
console.log("Link[1]:", nodes[1].getAttribute("href"));
...

Of course it’s better if you write a loop to print all the links. Something like :

for (let x = 0; x < nodes.length; x++) {
  console.log(nodes[x].getAttribute("href"));
}

Problem :

I need to get all the links in the table on this page : https://www.sahibinden.com/en/cars/used

I am using this library: https://www.npmjs.com/package/xpath-html

The issue is that when I print results it only gives me the first link.

let results = xpathT.fromPageSource(data).findElement("//tbody[@class='searchResultsRowClass']//a");
    
console.log("HERE NOSEDSS");
console.log(results);
console.log("The href value is:", results[1].getAttribute("href"));

How do I get all the links?

By