I searched SO and found a reference Accepted Answer but it did not solve my issue. I have a simple html dom which is:
<div class="name-hg">
<h2 class="head-name"><a href="http://www.example.com/example.html" title="Example title">Times have changed</a></h2>
<div class="sub-name">10 Things you did not know about time</div>
</div>
<div class="name-hg">
<h2 class="head-name"><a href="http://www.example.com/example.html" title="Example title">A Guide to mental fitness</a></h2>
<div class="sub-name">I am fit... mentally that is.</div>
</div>
<div class="name-hg">
<h2 class="head-name"><a href="http://www.example.com/example.html" title="Example title">Sllippers & Boots</a></h2>
<div class="sub-name">Fashion for the eccentric</div>
</div>
<div class="name-hg">
<h2 class="head-name"><a href="http://www.example.com/example.html" title="Example title">Bic Pen Era</a></h2>
<div class="sub-name">Your childhood could not have been better</div>
</div>
I am trying to use xPath to get all (a joined string) "head-name" and the "sub-name" class' content. My xPath expression did not succeed:
$x("string-join((//div[@class='name-hg']/h2[@class='head-name']/a/text(), //div[@class='name-hg']/div[@class='sub-name']/text()),' ')")
the error message I am getting, while trying it in Chrome's console, is:
Uncaught DOMException: Failed to execute 'evaluate' on 'Document': The string 'string-join((//div[@class='name-hg']/h2[@class='head-name']/a/text(), //div[@class='name-hg']/div[@class='sub-name']/text()),' ')' is not a valid XPath expression.(…)
If there is another expression I could use (like following sibling), would be nice.
thanks a lot