问题
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"
回答1:
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()]
回答2:
You may try using this:
//*[text()='Toltec Lighting']
来源:https://stackoverflow.com/questions/25470623/how-to-get-plain-text-with-xpath