Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get plain text with Xpath

Tags:

html

xpath

Hi I got this piece of html and i want to get text elements from it

<span id="product_description" itemprop="description" class="">
    <h1>Toltec Lighting 216-BRZ-508 Leaf Collection Traditional Potrack With Italian Marble Glass In Bronze</h1>
    <br class="">
    <span style="font-weight: bold;" class="">MANUFACTURE: </span>
    Toltec Lighting
    <br class=" xh-highlight">
    <span style="font-weight: bold;" class="">COLLECTION: </span>
    Leaf
    <br class=" xh-highlight">
</span>

I want to get list of values. In this case it will be "Toltec Lighting" and "Leaf"

like image 832
Vladimir Tsyupko Avatar asked Oct 25 '25 10:10

Vladimir Tsyupko


1 Answers

You can try this :

//span[@id='product_description']/text()

or if you need to also make sure no empty text nodes selected :

//span[@id='product_description']/text()[normalize-space()]
like image 173
har07 Avatar answered Oct 27 '25 01:10

har07