xpath - Import data from HTML page using feeds importer in drupal -



xpath - Import data from HTML page using feeds importer in drupal -

i'm trying import info html page feeds importer. context this:

<table class="tabela"> <tr valign="top"> <td class="formulario-legenda">nome:</td> <td nowrap="nowrap"> <b>raul fernando de almeida moreira vidal</b> </td> </tr> <tr valign="top"> <td class="formulario-legenda">sigla:</td> <td> <b>rmv</b> </td> </tr> <tr valign="top"> <td class="formulario-legenda">código:</td> <td>206415</td> </tr> <tr valign="top"> <td class="formulario-legenda">estado:</td> <td>ativo</td> </tr> </table> <table> <tr> <td class="topo"> <table> <tr> <td class="formulario-legenda">categoria:</td> <td>professor associado</td> </tr> <tr> <td class="formulario-legenda">carreira:</td> <td>pessoal docente de universidades</td> </tr> <tr> <td class="formulario-legenda">grupo profissional:</td> <td>docente</td> </tr> <tr valign="top"> <td class="formulario-legenda">departamento:</td> <td> <a href="uni_geral.unidade_view?pv_unidade=151" title="departamento de engenharia informática">departamento de engenharia informática</a> </td> </tr> </table> </td> </tr> </table>

i tried this:

/html/body/div/div/div/div/div/div/div/table/tbody/tr/td/table/tbody/tr[1]/td[2]

but nil appears. can help me right syntax obtain "grupo profissional"?

quick reply might work

considering html sample provided (which has 2 tables) can select text want using expression, based on table's position:

//table[2]//tr[3]/td[1]/text()

this will work in html pasted above. might not work in actual scenario, since might have other tables, table want select has no id , didn't suggest invariant text in code used anchor context expression. assuming initial part of xpath look (the div sequence) correct, might able use:

/html/body/div/div/div/div/div/div/div/table[2]//tr[3]/td[1]/text()

but it's wuite fragile look , vulnerable changes in document.

a (possibly) improve solution

a better alternative identifier use. can guess, since don't know code. in sample code, guess codigo , number next 206415 might identifier. if is, utilize anchor context. first select it:

//table[.//td[text()='código:']/following-sibling::td='206415']

the look above select table contains td exact text código: followed td containing exact text 206415. create unique context (considering number unique identifier). from context, can select text want, within next table (following-sibling::table[1]). context of sec table:

//table[.//td[text()='código:']/following-sibling::td='206415']/following-sibling::table[1]

and should select text want (grupo profissional:) in 3rd row tr[3] , first cell/column td[1] of table:

//table[.//td[text()='código:']/following-sibling::td='206415']/following-sibling::table[1]//tr[3]/td[1]/text()

xpath drupal-7

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -