tags:

views:

26

answers:

2

Hello,

In a previous question, user helped me but i'm stuck of doing simple request :

<?php $nodes = $xPath->query('//table[@class="some_class"]');

But it returns me the whole table datas instead of rows of the table, that's why i want to retrive only "td" of the table.

I tryed (but it's not working)

 <?php $nodes = $xPath->query('//table[@class="some_class"]/tbody/tr');

What am I doing wrong please ?

*EDIT HTML structure *

<table class="some_class">
<tbody><tr>
<td class="firstcol" width="160">name</td>
<td width="250">Some&nbsp;Data</td>
</tr>
+1  A: 

Assuming that the path matches correctly, you may just need to append /* to match all child nodes:

//table[@class="some_class"]/tbody/tr/*

Brabster
arg, not working, i updated my post with additional information. thanks
Tristan
@Tristan - "not working" should be a red flag saying "how do you know it's not working? Share that info." E.g. what value is $xPath->query() returning?
LarsH
I suspect that _if_ it's not working, it is because the OP used something like firebug / another DOM HTML presentation tool to look at HTML, which showed a `<tbody>`, but is using the source of a page, in which the `<tbody>` isn't present...
Wrikken
no return, no data displayed i meant :°). Thanks Wrikken, it may be the cause :)
Tristan
If it's the same http://www.esl.eu/fr/player/5178309/ again, there is indeed no `<tbody>`
Wrikken
yeap, thanks was looking with firebug the html structure. :')
Tristan
+5  A: 
//table[@class='some_class']//td

Added a middle // in there because of my mistrust at any level of tbody's actually being there (although for DOM they should be).

Wrikken
Thanks that's working
Tristan