Below, there is the part of some html page (all names of the parameters are in russian). It has the main class and two inner classes. The detailed html-code:
<div class="obj-params">
<div class="wrap">
<div class="obj-params-col" style="min-width:50%;">
<p>
<b>Param1_name</b>" Param1_value"</p>
<p>
<strong>Param2_name</strong>" Param2_value</p>
<p>
<strong>Param3_name</strong>" Param3_value"</p>
</div>
</div>
<div class="wrap">
<div class="obj-params-col">
<p>
<b>Param4_name</b>Param4_value</p>
<div class="inline-popup popup-hor left">
<b>Param5_name</b>
<a target="_blank" href="link">Param5_value</a></div></div>
I would like to extract the Param%d_value
's values. How can I do it using XPath?
I have tried the following expressions:
//div[@class="inline-popup popup-hor left"]/a/text() #extract correctly the name of the link
However, this expression forms me a list of all Param%d_value
instead of putting them in organized order:
//div[@class="obj-params"]/div[@class="obj-params-col"]/p/text()
The question is - how can I construct (per each param_value) XPath expression ? E.x. when I use the following XPath expression
//div[@class="obj-params"]//div[@class="obj-params-col"]/p/child::text()
['Param1_value, Param2_value, Param3_value, Param1_value, Param2_value, Param3_value, Param1_value, Param2_value, Param3_value']
what I need to get is the following:
XPath_expression_to_extract_only_Param1_value:
['Param1_value, Param1_value, Param1_value, Param1_value, Param1_value, Param1_value, Param1_value, Param1_value, Param1_value']
XPath_expression_to_extract_only_Param2_value:
['Param2_value, Param2_value, Param2_value, Param2_value, Param2_value, Param2_value, Param2_value, Param2_value, Param2_value']
XPath_expression_to_extract_only_Param3_value:
['Param3_value, Param3_value, Param3_value, Param3_value, Param3_value, Param3_value, Param3_value, Param3_value, Param3_value']
You can use
child::text()
to get the text nodes out of thediv
withobj-params-col
class:Demo (using
xmllint
):UPDATE:
If you need to get param value by param name, use: