XPATH that really highlights the background color of an RGB style?

Can someone tell me XPATH, which extracts the background color RGB values ​​or the whole style, then I will delete the unnecessary data using Excel find / replace.

You can retrieve car color names using XPATH // div [@ class = 'colorName']

<div class="colours" style="background-color: #040404; height: 30px; width: 130px; margin: 7px"></div>
<div class="colorName">Obsidian Black</div>

Source page: http://www.carwale.com/mercedesbenz-cars/e-class/e63amg-3049/

+4
source share
1 answer

You can use a combination of substring-after()and substring-before():

substring-before(substring-after(//div[@class="colours"]/@style, "background-color: "), ";") 

Works for me in chrome console:

> $x('substring-before(substring-after(//div[@class="colours"]/@style, "background-color: "), ";")')
"#040404"
+2
source

Source: https://habr.com/ru/post/1648953/


All Articles