I have such html files.
Basically it has div containing texts with one inner span and the rest text part has pretty arbitrary format.
<html>
<div>
<span class="c1">Text1</span><br/>
Text4<br/>
Text5
</div>
<div>
<span class="c1">TextA</span><a href="...">TextD</a>
</div>
</html>
it is trivial to select/print only specific text inside span with
xml sel -t -m "/html/div" -v "span[@class='c1']" -n
However I don't know how to select/print the rest text within but outside the span regardless of any other tags like <br/>
. The function text()
does not work as I expect.
xml sel -t -m "/html/div" -v "concat(span[@class='c1'],'|',text(),'$')" -n
will cut text behind <br/>
tags.
how can I get something like
Text1|
Text4
Text5$
TextA|TextD$
question from:
https://stackoverflow.com/questions/65864609/how-to-use-xmlstarlet-xpath-to-select-text-inside-div-but-exclude-some-inner 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…