Question

I am trying to retreive one specific element from HTML-code using QueryPath. It occurs twice, I only want the first one though. Searching for the object DOES work, but it returns me two elements. I was trying to add a pseudo-class-selector to my search, but that didn't work.

This is the HTML-element that occurs twice in the code:

<span class="aui-suffix"> of 5 </span>

And this is how I am searching for it:

$arrURL = "URL..."

$html = htmlqp( $arrURL );
$pageAsString = $html->find('span.aui-suffix');
echo $pageAsString->text();

The output is "of 5 of 5 ", which is both elements printed right after each other. How can I modify my search to get me only "of 5 "?

Was it helpful?

Solution

try $pageAsString = $html->find('span.aui-suffix:eq(0)');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top