xidel -se '//strong[@class="n-heading"][1]/text()[1]' 'https://www.anekalogam.co.id/id'
will print out 3 same outputs
15 June 2020
15 June 2020
15 June 2020
so, what should I do in order to choose only 1 of them?
edit:
inside the strong class, the value looks like this:
15 June 2020
How to print only the "15 June 2020"?
Let me illustrate why this happens with the following example.
'test.htm':
In other words, you have to put the "strong"-node between parentheses:
This isn't needed if you grab the parent-node instead:
[Bonus]
You've probably noticed already that the desired text-node spans 2 lines and ends with a
. To havexidelreturn just "15 June 2020":-
x:cps()is a shorthand forcodepoints-to-string()(andstring-to-codepoints()) and 160 is the codepoint for a "No-Break Space".-
text()[1]isn't needed, because whenever you feed a sequence to a filter that expects a string, only the first item of that sequence will be used.