JSFiddle - React, Tailwind, and code Playground
HTML
<a id="my">
testo a
<b>
testo z
</b>
</a>
JavaScript
console.log($x("//*[@id='my']//text()"));
<a id="my">
testo a
<b>
testo z
</b>
</a>
console.log($x("//*[@id='my']//text()"));