Xpath - Select element by filtering another node

Asked

Viewed 50 times

0

Good afternoon to all!
I need to build an xpath that returns the input only of the node containing the text VOLUNTARY CONTRIBUTION OF SELF-PROCLAIMED - TCSPREV contained in the /td

Follow the html code I’m using.

<tbody>
<tr class="rgRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__0">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl04$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl04_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl04_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl04$ctl00" disabled="disabled"></span></td><td>CONTRIBUIÇÃO BÁSICA DE ATIVO - TCSPREV</td><td>1000</td><td>09/05/1992</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2012/06</td>
</tr><tr class="rgAltRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__1">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl07$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl07_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl07_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl07$ctl00" disabled="disabled"></span></td><td>CONTRIBUIÇÃO VOLUNTÁRIA DE ATIVO - TCSPREV</td><td>1002</td><td>09/05/1992</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2012/06</td>
</tr><tr class="rgRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__2">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl10$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl10_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl10_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl10$ctl00" disabled="disabled"></span></td><td>CONTRIBUIÇÃO NORMAL DE ATIVO - TCSPREV</td><td>1004</td><td>09/05/1992</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2012/06</td>
</tr><tr class="rgAltRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__3">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl13$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl13_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl13_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl13$ctl00" checked="checked" disabled="disabled"></span></td><td>CONTRIBUIÇÃO BÁSICA DE AUTOPATROCINADO - TCSPREV</td><td>1005</td><td>13/06/2012</td><td>&nbsp;</td><td>0</td><td>MENSAL                        </td><td>2019/06</td>
</tr><tr class="rgRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__4">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl16$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl16_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl16_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl16$ctl00" checked="checked" disabled="disabled"></span></td><td>CONTRIBUIÇÃO VOLUNTÁRIA DE AUTOPATROCINADO - TCSPREV</td><td>1006</td><td>13/06/2012</td><td>&nbsp;</td><td>0</td><td>MENSAL                        </td><td>2019/06</td>
</tr><tr class="rgAltRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__5">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl19$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl19_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl19_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl19$ctl00" checked="checked" disabled="disabled"></span></td><td>CONTRIBUIÇÃO NORMAL DE AUTOPATROCINADO - TCSPREV</td><td>1008</td><td>13/06/2012</td><td>&nbsp;</td><td>0</td><td>MENSAL                        </td><td>2019/06</td>
</tr><tr class="rgRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__6">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl22$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl22_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl22_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl22$ctl00" disabled="disabled"></span></td><td>TAXA ADMINISTRATIVA DE ATIVO - TCSPREV</td><td>1010</td><td>09/05/1992</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2007/12</td>
</tr><tr class="rgAltRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__7">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl25$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl25_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl25_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl25$ctl00" disabled="disabled"></span></td><td>CONTRIBUIÇÃO BÁSICA DE ATIVO FÉRIAS - TCSPREV</td><td>1031</td><td>09/05/1992</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2012/03</td>
</tr><tr class="rgRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__8">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl28$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl28_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl28_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl28$ctl00" disabled="disabled"></span></td><td>CONTRIBUIÇÃO VOLUNTÁRIA DE ATIVO FÉRIAS- TCSPREV</td><td>1032</td><td>01/02/2011</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2012/03</td>
</tr><tr class="rgAltRow" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00__9">
    <td class="rgExpandCol"><input type="image" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl31$GECBtnExpandColumn" id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl31_GECBtnExpandColumn" title="Expand" src="/HotSite/Content/Images/icons/expand.png" alt="Expand"></td><td><span disabled="disabled"><input id="ctl00_ctl00_placeHolderMain_mainWebCad_grdContribuicoes_ctl00_ctl31_ctl00" type="checkbox" name="ctl00$ctl00$placeHolderMain$mainWebCad$grdContribuicoes$ctl00$ctl31$ctl00" disabled="disabled"></span></td><td>APORTE EXTRAORD PROJETO REVITALIZACAO CSC</td><td>1035</td><td>01/06/2012</td><td>12/06/2012</td><td>0</td><td>MENSAL                        </td><td>2012/06</td>
</tr>
</tbody>

xpath would be to "filter" by the previously reported text and return in the left arrow. Image below for understanding.

inserir a descrição da imagem aqui

1 answer

0


I managed to create the following xpath and achieve the expected result.

//tbody/tr[contains(.,'CONTRIBUIÇÃO VOLUNTÁRIA DE AUTOPATROCINADO - TCSPREV')]/td[1]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.