Reputation:
I have the following structure in an HTML document:
<li>
<b>fixed_keyword:</b> varying_text</li>
I want to get the varying_text
part to print with xmllint
. I have tried
xmllint --html --xpath "(//li[/b[text()='fixed_keyword:']]/text())"
xmllint --html --xpath "(//li)/b[text()='fixed_keyword:']/text()"
xmllint --html --xpath "(//li[text()='fixed_keyword:'])/text()"
and many more but nothing has worked so far.
What is the correct xpath expression to print varying_text
?
Upvotes: 1
Views: 67
Reputation: 473863
You need the following-sibling
axis:
//li/b[. = 'fixed_keyword:']/following-sibling::text()
Note that you don't have :
in the input HTML.
Upvotes: 1