excel - Take data from next HTML tag -


using html code example:

<table class="table-grid"> <tr> <th>auto.model</th>   <td>     <pre>'toyota avensis wagon'</pre>   </td> </tr> <tr> <th>auto.year</th>   <td>     <pre>2005</pre>  </td> </tr> </table> 

if take parameter "auto.model" between <th></th> tags , want receive "toyota avensis wagon", i.e. next expression between <pre></pre>. ideally i'd have function it.

thank @jeeped, code raise "type mismatch" error , points set el = param.previoussibling: sub extract_td_text() dim url string dim ie internetexplorer dim htmldoc htmldocument dim params ihtmlelementcollection dim param htmltablecell dim val htmltablecell dim r long dim el htmltablecell url = "my url" set ie = new internetexplorer ie .navigate url .visible = false 'wait page load while .busy or .readystate <> readystate_complete: doevents: wend set htmldoc = .document end set params = htmldoc.getelementsbytagname("tr") each param in params if param.innertext "*auto.model*" set el = param.previoussibling exit end if next if not el nothing debug.print el.innertext ie.quit set ie = nothing end sub

instead of using previoussibling, i'd suggest nextelementsibling.

from way html , vba codes set up, current 'param' value being passed should <th> tag. think previoussibling check tag comes before that, , since first element within <tr> (the parent element), there shouldn't (except maybe invisible node- previoussibling can find, don't need).

i think nextelementsibling should able find <td> tag, since comes after <th> tag.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -