Trying to extract content from class in HTML documment. Using PHPDomDocumment and DOMXpath.
Problem is class repeated seven times in HTML code. My parser works fine, getting deined values from classes, but i just want get value from one of them. Here is HTML:
<td class="myclass" width="25" align="center"><img src="https://somelink1.html" width="16" height="18" alt="." title="." /></td>
<td class="myclass" width="25" align="center"><img src="https://somelink.com" width="17" height="17" alt="" title="" /></td>
<td class="myclass">
<a title="TITLECONTENT." href="https://www.somelink.html" class="topictitle">LINKVALUE</a> <a href="https://www.somelink" class="topictitle" style="color: #">SOMETEXT</a>
</td>
<td class="myclass" width="130" align="center"><p class=""><a href="https://www.somelink.html" style="color: #FF3300;" class="username-coloured">SOMETEXT</a></p></td>
<td class="myclass" width="50" align="center"><p class="">5</p></td>
<td class="myclass" width="50" align="center"><p class="">1461</p></td>
<td class="myclass" width="140" align="center">
<p class="" style="white-space: nowrap;">7 lutego 2017, 10:08</p>
<p class=""><a href="https://www.somelink.html" style="color: #FF3300;" class="username-coloured">SOMETEXT</a>
<a href="https://><img src="https://" width="18" height="9" alt="" title="" /></a>
</p>
</td>
I just want extract content from third instance of class "myclass" others should be ommited.
Here is my Xpath query:
$finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), 'myclass')]");
There is a way to get content from just one selected instance of "myclass"?
Thanks!