web scraping - how to get specific text after a div with xpath -


i trouble specific texts located between 2 tags. mean, want text after em tag. want this. , text after p tag. want this.. there way of doing that? in advance.

<article>     <h1 id='h1'>heading 1</h1>     <img src='mypath/pictures/pic.jpg'></img>     <p></p>     <div id='div1'>         <time datetime='2016'>2016</time>     </div>     <br></br>     <em>my location, tn, united states</em>      text after em tag. want this.     <p></p>     text after p tag. want this.     <div id='div2'>     </div> </article> 

you can following sibling texts using

following-sibling::text() 

so em after text

//em/following-sibling::text()[1] 

the same p tag, , join them

string-join(em/following-sibling::text()[1] | p/following-sibling::text()[1] , ',') 

i hope help!


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -