OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

XPath select descendent of parents sibling

  • Thread starter Thread starter Lictor
  • Start date Start date
L

Lictor

Guest
This html is within my page:

Code:
<tr>
    <td class="padded2" bgcolor="#103A74"><font color="White">Refine by Vehicle Types</font></td>
    </tr><tr>
        <td class="padded2" bgcolor="White"><div>
            <table border="0">
                <tr>
                    <td class="padded2"><font color="#103A74"><ul><li><a class="padded2"> Cars</a></li><li><a class="padded2">Marine Engines</a></li><li><a class="padded2">Trucks</a></li></ul></font></td>
                </tr>
            </table>
        </div></td>
</tr>

I'm wanting to scrape "Cars" and "Trucks" based on the fact that they are after "Refine by Vehicle Type". I've tried many diferent ways and this is as close as I can get, but returns NULL.

Code:
$Nodes = $xPath->query("//tr/td/font[text()[contains(., 'Refine by Vehicle Type')]]/following-sibling::tr/td/div/table/tr/td/font/ul/li/a")->item(0)->nodeValue;

What am I missing?
<p>This html is within my page:</p>

<pre><code><tr>
<td class="padded2" bgcolor="#103A74"><font color="White">Refine by Vehicle Types</font></td>
</tr><tr>
<td class="padded2" bgcolor="White"><div>
<table border="0">
<tr>
<td class="padded2"><font color="#103A74"><ul><li><a class="padded2"> Cars</a></li><li><a class="padded2">Marine Engines</a></li><li><a class="padded2">Trucks</a></li></ul></font></td>
</tr>
</table>
</div></td>
</tr>
</code></pre>

<p>I'm wanting to scrape "Cars" and "Trucks" based on the fact that they are after "Refine by Vehicle Type".
I've tried many diferent ways and this is as close as I can get, but returns NULL.</p>

<pre><code>$Nodes = $xPath->query("//tr/td/font[text()[contains(., 'Refine by Vehicle Type')]]/following-sibling::tr/td/div/table/tr/td/font/ul/li/a")->item(0)->nodeValue;
</code></pre>

<p>What am I missing?</p>
Continue reading...
 

Latest posts

Top